Jump to content
Sign in to follow this  

Sample XML

Recommended Posts


maybe someone may find it useful :D

; ----------------------------------------------------------------------------
; sample how to retrieve XML information from a "non numbered list" when all items are "the same name"
; http://feeds2.feedburner.com/wettercom/rss

#cs sample like

    <description>Heute ...</description>
    <description>Der Tag ...</description>
author nobbe    04.2009

; ----------------------------------------------------------------------------
#include <inet.au3>
#include <array.au3>

; important for loading 
#include <_XMLDomWrapper.au3>


if $load_directy > 0 then 

    ; load directly
    $strXML= _INetGetSource("http://feeds2.feedburner.com/wettercom/rss")
    _XMLLoadXML($strXML, "")

else ; save into TEMP fiel first to check the XML data by hand 

    InetGet("http://feeds2.feedburner.com/wettercom/rss", @ScriptDir & "\weather.xml", 1, 0)
    $FileOpen = _XMLFileOpen(@ScriptDir & "\weather.xml")

    ; single item

    ;$node = "//rss/channel/item/description";
    ;$node = "//channel/item/description";
    ;$node = "//item/description";

    $title_node = "//rss/channel/item/title";
    $title_single = _GetFirstValue($title_node)

    If $title_single <> -1 Then
        MsgBox(0, "Title Single", $title_single)

    ;; multiple entries 

    $title_node = "//rss/channel/item/title";
    $title_array = _XMLGetValue($title_node)

    $descr_node = "//rss/channel/item/description";
    $descr_array = _XMLGetValue($descr_node)

    ; all array values : [0] holds number 
    For $i = 1 To $title_array[0]
        MsgBox(0, "Value " & $i, $title_array[$i] & @CRLF & @CRLF & $descr_array[$i])

exit ; 

; retruns array---
Func _GetFirstValue($node)
    $ret_val = _XMLGetValue($node)
    If IsArray($ret_val) Then
        _ArrayDisplay($ret_val, '_XMLGetValue  ' & $node)
        Return ($ret_val[1])
        Return SetError(1, 3, 0)
EndFunc   ;==>_GetFirstValue

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this