dcsimg
A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Load XML from site - works in preview, but not online???

  1. #1
    Senior Member
    Join Date
    Aug 2000
    Posts
    103

    Load XML from site - works in preview, but not online???

    Hi all,

    I'm using a simple bit of code below to pull some info about a weather feed. When I test in Flash, it works fine, but when I test online, it doesn't work at all, and doesn't retrieve ANY data.

    What is going wrong?

    Code:
    WEATHERXML = new XML();
    WEATHERXML.load("http://www.rssweather.com/rss.php?hwvUT=C&hwvUP=mb&hwvUS=kmh&hwvUV=km&hwvCCChange=forecast&hwvSF=Y&maxdays=2&daysonly=2&hwvStyle=ce&place=johannesburg%2B%2F%2Brand&country=ZA&icao=FAGM&alt=rss20a");
    WEATHERXML.onLoad = fParseXML;

  2. #2
    Novemberain Master
    Join Date
    Sep 2004
    Location
    Void
    Posts
    390
    You should...no...you must! set an onLoad handler before starting loading.

    The same thing with sound, etc.

    Try this. If it won't work, try to search this tremendous FAQ
    Last edited by Unsteady; 03-18-2005 at 08:23 AM.


    Never give up...

  3. #3
    Senior Member
    Join Date
    Aug 2000
    Posts
    103
    Thanks Unsteady.

    Never fear though, I found that the problem was a cross-domain one, and I discovered two workarounds, one simple, one super complex!

    simple: http://www.bgxcomponents.com/flashWeatherClient.htm.


    super complex: http://www.macromedia.com/cfusion/kn...fm?id=tn_16520

  4. #4
    Novemberain Master
    Join Date
    Sep 2004
    Location
    Void
    Posts
    390
    I thought of it, too. My congratulations!


    Never give up...

  5. #5
    Perverse Futurist villain2's Avatar
    Join Date
    Sep 2002
    Location
    Baltimore, MD
    Posts
    892
    Why not just use a php proxy file?

  6. #6
    Senior Member
    Join Date
    Aug 2000
    Posts
    103
    That's what I ended up doing actually :-)
    (Well, an asp proxy)....

  7. #7
    Actionscript idiot Mattgyver's Avatar
    Join Date
    May 2001
    Location
    Charlotte, NC
    Posts
    119
    How did you do your asp proxy? For some reason mine doesn't work. As follows:

    Here's an awesome problem. I want Flash to access an outside domain XML feed, specifically my weather.com account. This can normally be done with the following code:

    Code:

    // FLASH CODE
    var my_xml:XML = new XML();
    var myLoginReply_xml:XML = new XML();

    myLoginReply_xml.ignoreWhite = true;
    myLoginReply_xml.onLoad = onLoginReply;

    my_xml.sendAndLoad("getweather.asp", myLoginReply_xml);


    and the helper asp page:

    Code:

    <%@ Language=VBScript %>
    <%
    Dim url
    url="http://xoap.weather.com/weather/local/USNC0256?cc=*&dayf=4&prod=xoap&par=1012597020&key= bd646bbfde4c1efc"
    Response.ContentType="text/xml"
    Response.Redirect url
    %>

    Piece of cake right? Flash contacts the asp page, which brings in the xml feed from across the internet, so Flash thinks it it getting the original XML page. Genius. Well it doesn't work on IIS for some reason. I can get the same thing to work just fine when I rewrite the asp code to php code. But I'd prefer to know why the asp version doesn't work, and how to fix it.

    I am running IIS 6 on a Windows 2003 Web Edition server if that makes a difference.

    Any help would be appreciated. BTW, you can get a free weather.com XML feed account here: http://www.weather.com/services/xmloap.html

  8. #8
    Actionscript idiot Mattgyver's Avatar
    Join Date
    May 2001
    Location
    Charlotte, NC
    Posts
    119
    Got it working:

    <%@ LANGUAGE=VBScript%>
    <%
    Response.Buffer=True
    Dim MyConnection, TheURL

    ' Specifying the URL
    TheURL = "http://xoap.weather.com/weather/local/weather.xml"

    Set MyConnection = Server.CreateObject("Microsoft.XMLHTTP")
    ' Connecting to the URL
    MyConnection.Open "GET", TheURL, False

    ' Sending and getting data
    MyConnection.Send
    TheData = MyConnection.responseText

    'Set the appropriate content type
    Response.ContentType = MyConnection.getResponseHeader("Content-Type")
    Response.Write (TheData)

    Set MyConnection = Nothing
    %>

  9. #9
    ...::: ANNIYAN :::... chochweets's Avatar
    Join Date
    Mar 2005
    Posts
    255
    please send a sample file for "load xml from site"...



    Quote Originally Posted by aragorn23
    Hi all,

    I'm using a simple bit of code below to pull some info about a weather feed. When I test in Flash, it works fine, but when I test online, it doesn't work at all, and doesn't retrieve ANY data.

    What is going wrong?

    Code:
    WEATHERXML = new XML();
    WEATHERXML.load("http://www.rssweather.com/rss.php?hwvUT=C&hwvUP=mb&hwvUS=kmh&hwvUV=km&hwvCCChange=forecast&hwvSF=Y&maxdays=2&daysonly=2&hwvStyle=ce&place=johannesburg%2B%2F%2Brand&country=ZA&icao=FAGM&alt=rss20a");
    WEATHERXML.onLoad = fParseXML;
    have a good day

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center