Last active
August 29, 2015 14:17
-
-
Save kypflug/dde94c9ac62bc14a9004 to your computer and use it in GitHub Desktop.
XPath example from http://www.w3schools.com/xpath/tryit.asp?filename=try_xpath_select_cdnodes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// code for IE | |
if (window.ActiveXObject || xhttp.responseType == "msxml-document") { | |
xml.setProperty("SelectionLanguage", "XPath"); | |
nodes = xml.selectNodes(path); | |
for (i = 0; i < nodes.length; i++) { | |
document.write(nodes[i].childNodes[0].nodeValue); | |
document.write("<br>"); | |
} | |
} | |
// code for Chrome, Firefox, Opera, etc. | |
else if (document.implementation && document.implementation.createDocument) { | |
var nodes = xml.evaluate(path, xml, null, XPathResult.ANY_TYPE, null); | |
var result = nodes.iterateNext(); | |
while (result) { | |
document.write(result.childNodes[0].nodeValue); | |
document.write("<br>"); | |
result = nodes.iterateNext(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment