I have an XML
<root><example><examplevalue>exampletext</examplevalue><examplevalue>exampletext2</examplevalue</example></root>
and I have the following javscript code
if (window.DOMParser){ // Standard browsers
var parser = new DOMParser();
xmlDoc = parser.parseFromString(xmlString, "text/xml");
}
else { // Internet Explorer
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.loadXML(xmlString);
}
var coll=xmlDoc.getElementsByTagName("example");
console.log(coll[0].childNodes[0].nodeValue);
The console output is
null
I would expect it to be
exampletext
Why are the childnodes not parsed correctly?
childNodes seems to be a method of class node. But the getElementByName return a HTMLCollection object. How does that work?
Thanks for any hints.