XML parsing with Javascript

Discussion in 'Javascript' started by ArdGre, Aug 17, 2007.

  1. ArdGre

    ArdGre Guest

    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.
     
    ArdGre, Aug 17, 2007
    #1
    1. Advertising

  2. 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/
     
    Martin Honnen, Aug 17, 2007
    #2
    1. Advertising

  3. 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
     
    Bart Van der Donck, Aug 17, 2007
    #3
  4. 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/
     
    Martin Honnen, Aug 17, 2007
    #4
  5. 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
     
    Bart Van der Donck, Aug 17, 2007
    #5
  6. 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
     
    Thomas 'PointedEars' Lahn, Aug 17, 2007
    #6
  7. 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
     
    Bart Van der Donck, Aug 17, 2007
    #7
  8. 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>
     
    Thomas 'PointedEars' Lahn, Aug 17, 2007
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jason Jodon
    Replies:
    1
    Views:
    754
    Andy Dingley
    Dec 13, 2003
  2. Arun dudee

    xml parsing using javascript

    Arun dudee, Apr 14, 2007, in forum: XML
    Replies:
    0
    Views:
    380
    Arun dudee
    Apr 14, 2007
  3. John Levine
    Replies:
    0
    Views:
    756
    John Levine
    Feb 2, 2012
  4. Erik Wasser
    Replies:
    5
    Views:
    500
    Peter J. Holzer
    Mar 5, 2006
  5. noff
    Replies:
    0
    Views:
    228
Loading...

Share This Page