473,320 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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.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
1 3965


"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Andy Fish | last post by:
Hi, I'm trying to use <xsl:number> to generate a sequence number of all nodes that match a particular pattern, e.g: <xsl:template match="foo"> <xsl:copy> <xsl:attribute name="id"><xsl:number...
3
by: rob.guitar.rob | last post by:
Hello, My last few posts have been revolving aroung the same problem, and I still cant solve it and I would be really appreciate if anyone could spot a problem. a section of my XML goes like...
6
by: Tejpal Garhwal | last post by:
I have datagrid filled with some data rows. At the run time i want know how many total rows are there in the data grid ? Any idea ? Any Suggestions ? Thanks in advance Tej
2
by: Volkan | last post by:
Hi, I'm trying to compare two XML documents and i'm using XPath queries to select nodes. XPathNavigator's Select method runs fast enough and returns an XPathNodeIterator object. When i try to...
1
by: JS1 | last post by:
Hi there, How do I count the number of <Item> nodes for each <Message> in the following xml document? (Xml Document) <Message> <Order> <Item>1</Item> <Item>2</Item>
2
by: Norton Who | last post by:
Hi, Could I please ask if anyone could help me solve this problem in VS2003: I'm trying to count all the nodes that have a Checked state however this doesn't seem to be working for me. So...
1
by: emorrison | last post by:
I hope this isn't too vague, but I have a large XML file and when I try to use a count function in an XSL file to get the number of nodes, it returns 0 for a particular node. I can correctly count...
10
by: John Rogers | last post by:
This code only counts the parent nodes or rootnodes in a treeview, how do you count all the nodes in a treeview? // one way int NodeCounter = 0; foreach (TreeNode currentNode in...
9
by: smarttechie | last post by:
Hii all please help its urgent i have developed an application in xsl. what i want to do is i m searching the xml file based on a search.and based on that search im creating one tree like...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.