I am trying to extract values from the xml document and print them. I also want to count the number of children(child nodes) each node has.That is the first tag has 2 child and second tag has 3.
THIS IS THE XML DOCUMENT
<?xml version="1.0" ?>
<A>
<a1>a1</a1>
<a2>a2</a2>
<B>
<C>2</C>
<C>3</C>
</B>
<B>
<C>4</C>
<C>5</C>
<C>6</C>
</B>
</A>
THIS IS MY JAVASCRIPT DOCUMENT
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","extractexample.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
xmlObj=xmlDoc.documentElement;
document.write(xmlDoc.getElementsByTagName("B")[0].childNodes[0].nodeValue);