How can I use the selectNode() function on a parsed XML message in javascript?
<script>
var xmlStr = "<tagName>some text here</tagName>";
var xmlDoc = (new DOMParser()).parseFromString(xmlStr, "text/xml");
var nodes = xmlDoc.selectNodes('tagName');
</script>
I get error for this code: Uncaught TypeError: xmlDoc.selectNodes is not a function
Actually XmlDocument.SelectNodes method exists, but in the .NET Framework.
In JavaScript, you can use the getElementsByTagName() method
var nodes = xmlDoc.getElementsByTagName("tagName")[0];
selectNode() is not on javascript, you meant that you are looking for equivalent function?
nodes.getElementsByTagName("tagname");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With