I'm trying to parse an xml coming from an XMLHttpRequest (for a Firefox extension). In the following code, req is an XMLHttpRequest object. I did req.overrideMimeType("text/xml");
after declaring req.
var shortURL;
var xmlDoc = document.implementation.createDocument("","",null);
xmlDoc.async = false;
xmlDoc = req.responseXml;
if (xmlDoc.readyState == 4){
shortURL = xmlDoc.documentElement.childNodes[8].text;
}
If I use req.responseXml
I get an error saying "xmlDoc is not declared" for the line after xmlDoc = req.responseXml;
If I use req.responseText
, xmlDoc.readyState == 4
turns false.
I don't do much of javascript so please tell me if I'm doing something wrong here.