Home AMX User Forum NetLinx Studio
Options

read XML from Website

Dear all!

I need to read an XML file from a website, Someone know how to read the file thru code ?

http://www.meteowebcam.it/rss/Monfalcone.xml

Once I will have the file in the string event, I will parse the file myself.

Many thanks for the help,

Cris

Comments

  • Options
    viningvining Posts: 4,368
    All you can do is download it and parse it manually through code that you write. You can't use he VAR_TO_XML or XML_TO_VAR functions since they only work on a specific format created by the functions to work with structures.
  • Options
    DHawthorneDHawthorne Posts: 4,584
    There is a whole thread addressing how to get the content in your string event: http://www.amxforums.com/showthread.php?t=4406
  • Options
    criss87criss87 Posts: 32
    Solved !

    Work as a charm!
    Now I just need to parse all the incoming data....

    Many thanks,

    Cristiano



    button_event[tp,1]
    {
    push:
    {
    ip_client_open (dvHTML.Port,'www.meteowebcam.it',80,IP_TCP)
    }
    }

    data_event [dvHTML]
    {

    online:
    {
    clear_buffer cWeatherBuf

    send_string dvHTML,"'GET /rss/Monfalcone.xml HTTP/1.0',13,10"
    send_string dvHTML,"'Host: www.meteowebcam.it',13,10"
    send_string dvHTML,",13,10"
    }
    string:
    {
    // parsing data here soon.....
    }
    }
  • Options
    DHawthorneDHawthorne Posts: 4,584
    What I have done is iterate through the buffer by breaking out chunks with the > character. If the source is reasonably consistent, you can then test for a tag by looking for what follows the < in that chunk, and detecting a closing tag by looking for a / . Data itself would have no < in front of it.
Sign In or Register to comment.