By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,569 Members | 1,350 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,569 IT Pros & Developers. It's quick & easy.

Count Nodes

P: n/a
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.Current.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
Jun 27 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a


"Derek Hart" <de********@yahoo.comwrote in message
news:#W*************@TK2MSFTNGP02.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.Current.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)
http://joe.fawcett.name

Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.