Count Nodes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Derek Hart

    Count Nodes

    I wish to get a count of nodes in an xml file in vb.net, so I am using the
    following, as a simple example:



    MyCount = xmlNodePart.Cur rent.Select.//MyNode/Record[*]).Count



    I saw in some xml specs that instead of[*] it should be [@*], but that does
    not work. Why would the @ symbol be needed?



    Derek


  • Joe Fawcett

    #2
    Re: Count Nodes



    "Derek Hart" <derekmhart@yah oo.comwrote in message
    news:#WL0h6#1IH A.528@TK2MSFTNG P02.phx.gbl...
    I wish to get a count of nodes in an xml file in vb.net, so I am using the
    following, as a simple example:
    >
    >
    >
    MyCount = xmlNodePart.Cur rent.Select.//MyNode/Record[*]).Count
    >
    >
    >
    I saw in some xml specs that instead of[*] it should be [@*], but that
    does not work. Why would the @ symbol be needed?
    >
    >
    >
    Derek
    >
    >
    * represents a wildcard for current node type, normally this means all
    elements, @ is a shortcut for attributes so @* is all attributes.
    If you want all nodes in a file you do //node() or count(//node())
    The expression you gave, if it were legal, tries to do something different
    altogether. It is fetching the count of those Record elements that have a
    parent of MyNode and that have child elements.

    --

    Joe Fawcett (MVP - XML)


    Comment

    Working...