Jump to content

how to read a simple XML file with xmlDomWrapper


Recommended Posts

Hi

i never used XML and i don't know how to read a xml file properly...

i found the _XMLDomWrapper.au3 but i don't understand how to use it

i just want to read data from an xml like this:

<?xml version="1.0" encoding="utf-8"?>
<response>
 <count>21</count>
 <data>
  <firts>123434</first>
  <second>2342355</second>
  <title>something here</title>
  <url>http://asd.asd</url>
 </data>
 <data>
  <firts>745464</first>
  <second>574456</second>
  <title>something here too</title>
  <url>http://gfh.com/as/</url>
 </data>
 <data>
  ..........
 </data>
  ......
  ......
</response>

can someone please help me with this? with some examples?

thx a lot

Ivan

PS: sry for my bad english :S

Edited by IvanDream
Link to comment
Share on other sites

Like this...

#include"_XMLDomWrapper.au3"

$XMLFILE = "Doc.xml"

_XMLFileOpen($XMLFILE)

$iCount = _XMLGetNodeCount("/response/data")
Msgbox(0,"",$iCount)

For $i = 1 to $iCount

    $first = _XMLGetFirstValue("/response/data[" & $i & "]/first")
    $second = _XMLGetFirstValue("/response/data[" & $i & "]/second")
    $title = _XMLGetFirstValue("/response/data[" & $i & "]/title")
    $url = _XMLGetFirstValue("/response/data[" & $i & "]/url")

    MsgBox(0,"", $first & @crlf & $second & @crlf & $title & @crlf & $url)

Next


Func _XMLGetFirstValue($node)

    Local $ret_val

    $ret_val = _XMLGetValue($node)
    If IsArray($ret_val) Then
        Return ($ret_val[1])
    Else
        Return SetError(1,3,0)
    EndIf

EndFunc
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...