Team,
I am getting "Uncaught Error: NamespaceError: DOM Exception 14" in chrome. I have tried lot. Path is working for the same xml in 'http://www.xpathtester.com/test'. But when i write code it is not working. Please help.
NOTE:
I have tried this http://www.w3schools.com/xpath/tryit.asp?filename=try_xpath_select_cdnodes example.
If possible; kindly explain the function xml.evaluate(path, xml, null, XPathResult.ANY_TYPE, null)
and its arguments.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript">
function loadXMLDoc(dname)
{
if (window.XMLHttpRequest)
{
xhttp=new XMLHttpRequest();
}
else
{
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET",dname,false);
xhttp.send("");
return xhttp.responseXML;
}
function Test(){
xml=loadXMLDoc("config.xml");
path="/SOAP-ENV:root/SOAP-ENV:Envelope/SOAP-ENV:Body/child::node()";
// code for IE
if (window.ActiveXObject) {
var nodes=xml.selectNodes(path);
for (i=0;i<nodes.length;i++) {
document.write(nodes[i].childNodes[0].nodeValue);
document.write("<br>");
}
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument){
var nodes=xml.evaluate(path, xml, null, XPathResult.ANY_TYPE, null); //Exception
var result=nodes.iterateNext();
while (result) {
document.write(result.childNodes[0].nodeValue);
document.write("<br>");
result=nodes.iterateNext();
}
}
}
</script>
</head>
<body>
<button type="button" onclick=Test()>Display Date</button>
</body>
</html>
And My xml is
<?xml version="1.0"?>
<SOAP-ENV:root xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header></SOAP-ENV:Header>
<SOAP-ENV:Body>
<m:Activate xmlns:m="http://schemas.method.com"><resultCode>0</resultCode>
</m:Activate>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>