Jump to content

How to extract data from an xml string?


Gulae
 Share

Recommended Posts

Hello all,

I want to extract data from a website (this data is given in a xml structure). This is going ok with the following code:

CODE
; AutoIt test

#include <Inet.au3>

;Define adress of the website

Local $url = "https://api.games.betfair.com/rest/v1/channels/1444077/snapshot"

;retreive data from the website

Local $data = _InetGetSource($url)

;write retreived data to console to check output manually

ConsoleWrite($data)

I just write the retreived data to the console here, so I have a visual of how this xml structure looks like. The meaning is now that I'm gonna store all data from this xml-file into a txt file (or whatever layout), but herefore I need to extract this data from this xml structure. Is there any standard way for doing this in autoit?

example of the extracted xml :

CODE

<channel gameType="BLACKJACK" id="1444077" name="Exchange BlackJack">

<status>RUNNING</status>

<game id="1576601">

<round>5</round>

<bettingWindowTime>30</bettingWindowTime>

<bettingWindowPercentageComplete>100</bettingWindowPercentageComplete>

<gameData>

<object name="Player 1">

<description>13 Points</description>

<status>STOOD</status>

<property name="Card 1" value="8"/>

<property name="Card 2" value="29"/>

</object>

<object name="Player 2">

<description>20 Points</description>

<status>STOOD</status>

<property name="Card 1" value="37"/>

<property name="Card 2" value="12"/>

</object>

<object name="Player 3">

<description>20 Points</description>

<status>STOOD</status>

<property name="Card 1" value="48"/>

<property name="Card 2" value="37"/>

</object>

<object name="Player 4">

<description>21 Points - Blackjack</description>

<status>STOOD</status>

<property name="Card 1" value="39"/>

<property name="Card 2" value="50"/>

</object>

<object name="Dealer">

<description>15 Points</description>

<status>IN_PLAY</status>

<property name="Card 1" value="43"/>

<property name="Card 2" value="31"/>

<property name="Card 3" value="16"/>

</object>

</gameData>

</game>

</channel>

</channelSnapshot>

Link to comment
Share on other sites

  • Moderators

Did the same search before (even with other strings) but couldn't find any usefull, that's why I posted my question in the first place,

thx anyway

Your answer is in like one of the top 5 questions... so to say you didn't find anything useful, is to say you didn't look very hard.

I don't understand why you haven't cracked open the help file, and since you use the the term "strings" looked at the String* functions to see which would help you.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

The string functions aren't really what I'm after here.

After searching more in detail, I finally found what i needed in one of the topics (and yes it was under the single "xml" search topics). ==> click here

and yes, maybe I should have searched harder the first time before posting my question,

thx again

ps : I only hoped for a more constructive answer then just a link (this lets me feel like a #######)

pss : You guys are doing a great job, otherwise I wouldn't be using autoit and browsing here for answers

Link to comment
Share on other sites

  • Moderators

The string functions aren't really what I'm after here.

After searching more in detail, I finally found what i needed in one of the topics (and yes it was under the single "xml" search topics). ==> click here

and yes, maybe I should have searched harder the first time before posting my question,

thx again

ps : I only hoped for a more constructive answer then just a link (this lets me feel like a #######)

pss : You guys are doing a great job, otherwise I wouldn't be using autoit and browsing here for answers

You'd get constructive answers, if you provide a constructive question. Just saying you are trying to get information from an .xml file doesn't help much. Telling us what type of information you are trying to get, probably would have gotten you a lot further than what it did. Your answer, as far as I am concerned, was in the 5th post on the link I provided... I shouldn't have to "draw" it out for you if you have the ability to read.

I know how to get any part of that information you want, but considering what site it is coming from, and having absolutely no idea how you are wanting to use it, I wouldn't have posted the answer specifically regardless.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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...