Convert String to XML Object Where DOMParser Is Not Supported

V

vunet

I used DOMParser to convert a response string to XML object:

DOMParser.parseFromString()

In browsers where DOMParser is not supported (Safari 1-2 for my case)
I cannot use DOMParser. What method is normally used to convert a
string to XML object. For Firefox I use E4X. For IE I use
ActiveXObject loadXML() method.

Thanks.
 
M

Martin Honnen

vunet said:
I used DOMParser to convert a response string to XML object:

DOMParser.parseFromString()

In browsers where DOMParser is not supported (Safari 1-2 for my case)
I cannot use DOMParser.

I have not tried it but I think I remember some suggesting to use
XMLHttpRequest with a data: URL. So assuming Safari 1.2 has
XMLHttpRequest and supports data: URLs you would do
var string = '<foo>bar</foo>';
var httpRequest = new XMLHttpRequest();
httpRequest.open('GET', 'data:application/xml,' +
encodeURIComponent(string), true);
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState === 4) {
alert(httpRequest.responseXML.documentElement.firstChild.nodeValue);
}
};
httpRequest.send(null);
 
V

vunet

I have not tried it but I think I remember some suggesting to use
XMLHttpRequest with a data: URL. So assuming Safari 1.2 has
XMLHttpRequest and supports data: URLs you would do
var string = '<foo>bar</foo>';
var httpRequest = new XMLHttpRequest();
httpRequest.open('GET', 'data:application/xml,' +
encodeURIComponent(string), true);
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState === 4) {
alert(httpRequest.responseXML.documentElement.firstChild.nodeValue);
}
};
httpRequest.send(null);

Thanks.
It did not work in Safari 1.3. In Firefox, however, it gave me an
error: "Permission denied to call method XMLHttpRequest.open"
 
M

Martin Honnen

vunet said:
It did not work in Safari 1.3.

It did not work? As said I have not tested that myself but blog entries
In Firefox, however, it gave me an
error: "Permission denied to call method XMLHttpRequest.open"

Well Firefox has DOMParser so I don't understand why you tried the data:
URL approach with Firefox.
 
V

vunet

It did not work? As said I have not tested that myself but blog entries


Well Firefox has DOMParser so I don't understand why you tried the data:
URL approach with Firefox.

You are right. But I just wanted to see the behavior. Anyway, where do
I look for a solution? Thanks.
 
T

Thomas 'PointedEars' Lahn

vunet said:
As mentioned in one of the comments, it does not work on Mac Safari
1.3. I have exact same problem.

Safari 1.3 is hopelessly outdated.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
EmeliaBryc

Latest Threads

Top