I have an XML document like this:
<section>
<description></description>
<question>
<description></description>
</question>
</section>
I have got the sectionXML stored in a variable called SectionXML. I use:
section.description = SectionXML.getElementsByTagName("description")[0].childNodes[0];
section.description = section.description ? section.description.nodeValue : "";
However, SectionXML.getElementsByTagName("description")
returns a list of many descriptions, as if we look many children deeper (great grand children etc) we can see they all have a description, but I just want to get the immediate child of SectionXML with the tag name of "description". How do I do that?
No comments:
Post a Comment