...

View Full Version : XML Validation



Me_Titus
06-14-2007, 07:03 PM
HI guys,

when using this property from the xmlHttpRequest "responseXML", how can one check is the xml is valid.

Thanks,

MeTitus

rnd me
06-15-2007, 07:11 AM
it is typically empty if it is not...

you could also use responseText, and parse it yourself to make double sure:



function mkXML(text) {
if (typeof DOMParser != "undefined") {
return (new DOMParser).parseFromString(text, "text/xml");
} else if (typeof ActiveXObject != "undefined") {
var doc = new ActiveXObject("MSXML2.DOMDocument");
doc.loadXML(text);
return doc;
} else {
var url = "data:text/xml;charset=utf-8," + encodeURIComponent(text);
var request = new XMLHttpRequest;
request.open("GET", url, false);
request.send(null);
return request.responseXML;
}
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum