Hi,
My xml is this which is returned by a webservice:
<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="http://tempuri.org/">
<NewDataSet>
<WR_district>
<state_name>
WEST BENGAL
</state_name>
<area>6751862238.46765</area>
<dist>BARDDHAMAN</dist>
<district_>438</district_>
<dstrict__1>295</dstrict__1>
<dstrict_po>454</dstrict_po>
<indiadpo_1>36</indiadpo_1>
<indiadpoly>309</indiadpoly>
</WR_district>
</NewDataSet>
</string>
Is it well formed or not?
and my code is this:
var xmlHttpObj = CreateXmlHttpRequestObject();
if (xmlHttpObj != null) {
xmlHttpObj.onreadystatechange = onResponse;
alert('here');
xmlHttpObj.open("GET", url, false);
alert('here1')
xmlHttpObj.setRequestHeader("Content-Type", "text/xml");
//alert('here2');
xmlHttpObj.send("arg1=" + tbname + "&arg2=" + pointWKT);
alert('here3');
}
else {
alert("Your browser does not support XMLHTTP.");
}
function onResponse() {
if (xmlHttpObj.readyState != READYSTATE_COMPLETE) return;
if (xmlHttpObj.status != 200) {
alert(xmlHttpObj.status);
alert("Problem retrieving XML data");
return;
}
alert(xmlHttpObj.status);
//txt = "<table border='1'>";
x = xmlHttpObj.responseXML;
alert(x);
var data = x.documentElement.getElementByTagName("NewDataSet");
alert("data:" +data);
// for (i = 0; i < x.allNodes.childNode[0].length; i++)
// {
// var stateName = data.getElementByTagName("state").childNodes[0].nodeValue;
// var statepopulation = data.getElementByTagName("pop_tot01").childNodes[0].nodeValue;
// var stateMales = data.getElementByTagName("males01").childNodes[0].nodeValue;
// var stateFemales = data.getElementByTagName("females01").childNodes[0].nodeValue;
// alert(data.getElementByTagName("state"));
// alert(stateName + "\n" + statepopulation + "\n" + stateMales + "\n" + stateFemales);
// }
}
Now xmlHttpObj.responseXML.documentElement is null but xmlHttpObj.responseXML is an object.But can I parse xmlHttpObj.responseXML.
Thanks for your reply.