Have you received this XML file via an XMLHttpRequest
? If so, you can use its responseXML
property.
alert(xhr.responseXML.documentElement.getAttribute("statusLocation"));
Or with jQuery:
$.ajax({
type: "GET",
url: "yourfile.xml",
dataType: "xml",
success: function(xml) {
alert(xml.documentElement.getAttribute("statusLocation"));
}
});
Here is one way to do it:
var xml = null;
function loadXML(myURL){
$.ajax({
type: "GET",
url: myURL,
dataType: ($.browser.msie) ? "text" : "xml",
error: function(){
return;
},
success: function(data){
if (typeof data == "string") {
xml = new ActiveXObject("Microsoft.XMLDOM");
xml.async = false;
xml.loadXML(data);
} else {
xml = data;
}
}
});
};
$(loadXML("common/glossary.xml"));
then
$(xml).find('something')