Javascript XML Parser with same name of parent and child nodes



I am trying to parse a complex kind of xml with javascript and when I try to get the tag names.


This is the example XML:



<node:a>
<node:a>value1</node:a>
<node:a>value2</node:a>
....
....
<node:a>valueN</node:a>
</node:a>

<node:a>
<node:a>value1</node:a>
<node:a>value2</node:a>
....
....
<node:a>valueN</node:a>
</node:a>

......

......

<node:a>
<node:a>value1</node:a>
<node:a>value2</node:a>
....
....
<node:a>valueN</node:a>
</node:a>


This is what I do:



xmlDoc.getElementsByTagName("node:a").length


It returns the length like this: All main tags with + All of the sub tags with


What I want is:


I want to get only the main tags (parent tags) and then I want to iterate over the parent tag one by one to get the child tags and their values.


Pardon me, if my question is too dumb.


Thanks


No comments:

Post a Comment