xhttp.open('GET', url, true);
xhttp.setRequestHeader('Content-Type', 'text/xml');
xhttp.send("");
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4) {
xml = xhttp.responseXML;
callback();
}
}
Of course I can get the data with x.responseText but then I can't
really use functions like getElementsByTagName(). There shouldn't be
anything wrong with the XML-file.
Any help would be appreciated.
xhttp.overrideMimeType('text/xml');
var domParser = new DOMParser();
var doc = domParser.parseFromString(xhttp.responseText, "text/xml");
var elements = doc.getElementsByTagName("... your elements ...");
--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.
Okay, I've tried by setting the MIME-type and also with the DOMParser.
Nothing. Okay, with MIME and without DOMParser and by setting
xhttp.responseText it gives me TypeError: Object ... has no method
'getElementsByTagName'. With the another setting that you described
var domParser = new DOMParser();
domWith var doc = domParser.parseFromString(xhttp.responseText,
"text/xml");
it won't even call the callback-function but stops there.
Can this be because of the structure of the program? Because first it
calls a method to get the xml (background.html), after which it calls
a method to create a new tab which fires an event to get the XML-data
from background.html. I have tried this with the responseText and it
gets the information though in wrong format. Other options given here
and elsewhere hasn't worked. So I guess there's something wrong with
the XML-file (which I guess isn't right because FF reads it and is
from an authority which I believe to be correct in this)? Or am I
missing something here? In callback-function after creating a new tab
I have just implemented a test line something like this:
document.getElementById("div_").innerHTML = "foo";
which I can see with responseText setting but,
I can't even get there if I use xhttp.responseXML.
If I'm using xhttp.ResponseText and something like this:
function callback(data) {
document.getElementById("div_").innerHTML = data;
}
I can see the XML-data in the div as Chrome displays it by the default
but I'm not able to use the methods as I described in the first post.