XML parsing with Javascript

A

ArdGre

HI THERE,

I have a strange problem. I am writing a firefox extension to the
Onlywire API (http://onlywire.com/index?api). Now the problem is when
I tag pages using the onlywire API the service responds with an xml
that indicates whether the web page was tagged successfully.
Something like this:

<?xml version="1.0"?>
<result code="success" />

Now using the api requires http authentication. After the
authentication succeeds the service responds with an xml file. Now,
the problem is that I dont want the users to see this xml file, I want
to somehow parse the xml file that I receive and display appropriate
message in a popup box.

Any help would be just great. Thanks.

Cheers.
 
M

Martin Honnen

ArdGre said:
Now using the api requires http authentication. After the
authentication succeeds the service responds with an xml file. Now,
the problem is that I dont want the users to see this xml file, I want
to somehow parse the xml file that I receive and display appropriate
message in a popup box.

You can use XMLHttpRequest
<http://www.xulplanet.com/references/objref/XMLHttpRequest.html> to make
the request, the open method takes username and password as optional
parameters and you can use the responseXML object to access the XML sent
as the response.
 
B

Bart Van der Donck

Martin said:
You can use XMLHttpRequest
<http://www.xulplanet.com/references/objref/XMLHttpRequest.html> to make
the request, the open method takes username and password as optional
parameters and you can use the responseXML object to access the XML sent
as the response.

If I understand correctly, I don't think XMLHttpRequest is suitable
here, because it looks like the submission is always done to www.onlywire.com
(another domain).

Since the sandbox model doesn't allow access to this XML response, I
think the only possibility is to perform the request from a server
script. And then parse the response at server before returning output
to client.
 
M

Martin Honnen

Bart said:
If I understand correctly, I don't think XMLHttpRequest is suitable
here, because it looks like the submission is always done to www.onlywire.com
(another domain).

The original poster is writing a Firefox extension and not some script
in a web page.
 
B

Bart Van der Donck

Martin said:
The original poster is writing a Firefox extension and not some script
in a web page.

I don't have any experience in those, but wouldn't XMLHttpRequest need
to go to the other domain anyhow (namely, to onlywire.com) ? Or is it
possible to grab URL's from remote servers with XMLHttpRequest in
Firefox extensions ?
 
T

Thomas 'PointedEars' Lahn

Bart said:
I don't have any experience in those, but wouldn't XMLHttpRequest need
to go to the other domain anyhow (namely, to onlywire.com) ? Or is it
possible to grab URL's from remote servers with XMLHttpRequest in
Firefox extensions ?

I know of no restrictions for Firefox/Gecko extensions. There is even a
Firefox extension written in JavaScript that can display the IP address of
the accessed and the accessing host through XPCOM, among other things. [1]
It is very likely that the Same Origin Policy does not apply here.


PointedEars
___________
[1] https://addons.mozilla.org/de/firefox/addon/590
 
B

Bart Van der Donck

Thomas said:
Bart said:
Is it possible to grab URL's from remote servers with XMLHttpRequest
in Firefox extensions ?

I know of no restrictions for Firefox/Gecko extensions. [...]
It is very likely that the Same Origin Policy does not apply here.

I would be surprised. Care to backup this claim ?
 
T

Thomas 'PointedEars' Lahn

Bart said:
Thomas said:
Bart said:
Is it possible to grab URL's from remote servers with XMLHttpRequest
in Firefox extensions ?
I know of no restrictions for Firefox/Gecko extensions. [...]
It is very likely that the Same Origin Policy does not apply here.

I would be surprised.

Have I not just proved that extensions can do more than the average
client-side Web script?
Care to backup this claim ?

I have not claimed anything, so I have nothing to back up.


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
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top