I am running a request to an xml file like this :
function load()
{
var request=new XMLHttpRequest();
request.open("GET","response.xml",true);
request.send();
request.onreadystatechange=function()
{
if(request.readyState==4)
{
var x=request.responseXML;
var y=x.getElementsByTagName("Limits")[0].childNodes[1];
var z=y.getElementsByTagName("Limits")[0].childNodes[0];
document.write(z)
}
}
}
The xml response.xml is this:
<Factory>
<Limits>
<Point X="92" Y="489">hahahahff</Point>
<Point X="570" Y="487">1111</Point>
<Point X="570" Y="138">33333</Point>
<Point X="92" Y="140">44444444</Point>
<Point X="92" Y="139">5555555</Point>
</Limits>
<Cells>
<Cell>
<Point X="358" Y="138"/>
<Point X="361" Y="487"/>
<Point X="570" Y="487"/>
<Point X="570" Y="138"/>
<Point X="358" Y="138"/>
</Cell>
<Cell>
<Point X="311" Y="139"/>
<Point X="311" Y="488"/>
<Point X="92" Y="489"/>
<Point X="92" Y="140"/>
<Point X="311" Y="139"/>
</Cell>
</Cells> </Factory>
I get this error :
Cannot read property 'childNodes' of undefined
why is this happening ? what i am trying to achieve is print the value of the 2nd 'POINT' node WITHOUT using getElementsByTagName("POINT")[1]. Basically I want to 'enter' the Limits node, and print the 2nd value.
No comments:
Post a Comment