How to count the Childnodes of one specific node in XML file using VBA

S

sam

Hi,

In order to judge the quantity of tables in one section of word
document, I need to count the childnodes of one specific node in one
XML file first. Here is an XML file sample.
<?xml version="1.0"?>
<CATALOG>
<CD>
.....
</CD>
<CD>
.....
</CD>
<CD>
....
</CD>
</CATALOG>

I want to count how many CDs under the node---CATALOG. This also means
how many childnodes CATALOG have. Could you give me a sample code to
count it? Thank you in advance!!!

Best Regards

Sam
 
S

sam

HI, Jonathan

Thank you for your help!

I tried some simple applications in VBA editor,after I setthe reference
to XML v4.0. However, in the tutorial you mention in last post. I
didn't find some info about count childnodes. Could you give me some
hints on counting the children of Catalog as I mentioned in the sample
of thread 1.

Best Regards

Sam
 
J

Jonathan West

sam said:
HI, Jonathan

Thank you for your help!

I tried some simple applications in VBA editor,after I setthe reference
to XML v4.0. However, in the tutorial you mention in last post. I
didn't find some info about count childnodes. Could you give me some
hints on counting the children of Catalog as I mentioned in the sample
of thread 1.

Best Regards

Take a look here
http://www.w3schools.com/dom/dom_access.asp

and scroll down to "Traversing the Node-tree". In addition, once you have
set the reference to the XML parser in VBA, you can press F2 and view the
entire object hierarchy - including all the collections and properties.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top