First: your xml code, first line reads
Code:
<?xml version=1.0"?>
It should be
Code:
<?xml version="1.0"?>
I saved it as location.xml
This html does what you want:
Code:
<!DOCTYPE html>
<html>
<body>
<script>
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","location.xml",false);
xmlhttp.send('');
xmlDoc=xmlhttp.responseXML;
var x=xmlDoc.getElementsByTagName("loc");
for (i=0;i<x.length;i++)
{
if(x[i].getElementsByTagName("id")[0].childNodes[0].nodeValue == 122)
{
document.write(x[i].getElementsByTagName("id")[0].childNodes[0].nodeValue+"<br />");
document.write(x[i].getElementsByTagName("user")[0].childNodes[0].nodeValue+"<br />");
document.write(x[i].getElementsByTagName("section")[0].childNodes[0].nodeValue);
}
}
</script>
</body>
</html>