Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > XML parsing with Javascript

Reply
Thread Tools

XML parsing with Javascript

 
 
ArdGre
Guest
Posts: n/a
 
      08-17-2007
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.

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      08-17-2007
ArdGre wrote:

> 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.

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
Bart Van der Donck
Guest
Posts: n/a
 
      08-17-2007
Martin Honnen wrote:

> ArdGre wrote:
>> 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.


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.

--
Bart

 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      08-17-2007
Bart Van der Donck wrote:

> 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.


--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
Bart Van der Donck
Guest
Posts: n/a
 
      08-17-2007
Martin Honnen wrote:

> Bart Van der Donck wrote:
>
>> If I understand correctly, I don't think XMLHttpRequest is suitable
>> here, because it looks like the submission is always done towww.onlywire.com
>> (another domain).

>
> 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 ?

--
Bart

 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      08-17-2007
Bart Van der Donck wrote:
> Martin Honnen wrote:
>> Bart Van der Donck wrote:
>>> If I understand correctly, I don't think XMLHttpRequest is suitable
>>> here, because it looks like the submission is always done towww.onlywire.com
>>> (another domain).

>> 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 ?


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
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
 
Reply With Quote
 
Bart Van der Donck
Guest
Posts: n/a
 
      08-17-2007
Thomas 'PointedEars' Lahn wrote:

> Bart Van der Donck wrote:
>
>> 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 ?

--
Bart

 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      08-17-2007
Bart Van der Donck wrote:
> Thomas 'PointedEars' Lahn wrote:
>> Bart Van der Donck wrote:
>>> 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
--
"Use any version of Microsoft Frontpage to create your site. (This won't
prevent people from viewing your source, but no one will want to steal it.)"
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What libraries should I use for MIME parsing, XML parsing, and MySQL ? John Levine Ruby 0 02-02-2012 11:15 PM
Working with XML in JavaScript / Как работать с XML в Javascript'е? noff Javascript 0 06-14-2007 12:46 PM
Different results parsing a XML file with XML::Simple (XML::Sax vs. XML::Parser) Erik Wasser Perl Misc 5 03-05-2006 10:09 PM
Print XML parsing to JspWriter (out) Class org.xml.sax.helpers.NewInstance can not access a member of class javax.xml.parsers.SAXParser with modifiers "protected" Per Magnus L?vold Java 0 11-15-2004 02:27 PM
Parsing XML with Javascript - newbie question Jason Jodon XML 1 12-13-2003 05:41 PM



Advertisments