Loading remote xml

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • J_Zanetti

    Loading remote xml

    Hello everybody,

    I would need to load through javascript a remote xml file (a rss feed)
    and then use its content to build the page. I am trying to do something
    in my local pc and it works fine in IE but in firefox it seems that
    remote files cannot be retrieved. So how would it be possilbe to build
    a rss ticker entirely in JS working in firefox? The only solution is an
    Ajax call??

    Thanks very much to anyone who will be able to help me ;)

    J_Z

  • Martin Honnen

    #2
    Re: Loading remote xml

    J_Zanetti wrote:
    I would need to load through javascript a remote xml file (a rss feed)
    and then use its content to build the page. I am trying to do something
    in my local pc and it works fine in IE but in firefox it seems that
    remote files cannot be retrieved. So how would it be possilbe to build
    a rss ticker entirely in JS working in firefox? The only solution is an
    Ajax call??
    Your script in a HTML document loaded from e.g. http://example.com/ can
    only load XML from http://example.com/ but not from other origins.


    --

    Martin Honnen

    Comment

    • J_Zanetti

      #3
      Re: Loading remote xml

      Martin Honnen ha scritto:
      Your script in a HTML document loaded from e.g. http://example.com/ can
      only load XML from http://example.com/ but not from other origins.
      Martin, thank you for your answer.
      I knew about this, but why does it work on IE?? In IE i created rss
      tickers with js and they work on my pc (so i guess also from other
      servers).
      I got lost on this point :S

      Thanks so much!

      Comment

      • Martin Honnen

        #4
        Re: Loading remote xml

        J_Zanetti wrote:
        I knew about this, but why does it work on IE?? In IE i created rss
        tickers with js and they work on my pc (so i guess also from other
        servers).
        I got lost on this point :S
        IE has different security zones each of which can be configured to allow
        such access. So it depends on the zone (e.g. file system, intranet zone,
        internet zone, trusted sites) and its configuration whether the access
        across domains works in IE or not.


        --

        Martin Honnen

        Comment

        • shimmyshack

          #5
          Re: Loading remote xml

          you will need a proxy script on your server on the same domain as the
          ajax call, from which the ajax gets its data.

          this gets called by the ajax script.
          <?php
          header( 'Content_type: text/xml' );
          readfile( 'http://remote.domain.c om/rss/feed.xml' );
          ?>

          you make the proxy as complicated as it needs to be, so that it
          retrieves multiple rss for your XHR calls.

          It's not hard to make so there must be a tonne of them out there, they
          are even used for flash as well, because of its crossdomain
          restrictions.

          Also it's a VERY good idea to parse the remote rss scripts first to
          remove the possibility of introducing XSS attacks into your html by
          directly including the remote scripts. Its my opinion that php or a
          server side language would have a much better chance of collecting
          feeds which require cookies or other crendentials as well, so a pure JS
          implementation would have feature limitations.

          Comment

          • J_Zanetti

            #6
            Re: Loading remote xml


            shimmyshack ha scritto:
            you will need a proxy script on your server on the same domain as the
            ajax call, from which the ajax gets its data.
            Thank you shimmyshack!

            I see this is a nice workout for a serverside application! Looks very
            interesting and powerful!
            Though, i start to think there's no solution for a client script that
            makes the job in Firefox at least...

            Thanks again!

            Comment

            Working...