Solved

vb.net -> Reading xml file

Posted on 2014-02-12
4
453 Views
Last Modified: 2014-02-28
Hi,

I have the following in an XML file (Please see below) and i would like to pull these stats

home":{"name":"Arka Gdynia","score":"0"}
"away":{"name":"Stomil Olsztyn","score":"0",
"timeElapsed":63


[{"eventTypeId":1,"eventId":27144224,"score":{"home":{"name":"Arka Gdynia","score":"0","games":"","sets":""},"away":{"name":"Stomil Olsztyn","score":"0","games":"","sets":""}},"timeElapsed":63,"fullTimeElapsed":{"hour":0,"min":0,"sec":0},"status":"SecondHalfKickOff","matchStatus":"SecondHalfKickOff"},{"eventTypeId":1,"eventId":27147134,"score":{"home":{"name":"Qalali Club","score":"1","games":"","sets":""},"away":{"name":"Al Tadamun Buri","score":"0","games":"","sets":""}},"timeElapsed":42,"fullTimeElapsed":{"hour":0,"min":0,"sec":0},"status":"KickOff","matchStatus":"KickOff"},{"eventTypeId":1,"eventId":27147133,"score":{"home":{"name":"Al Ahli","score":"0","games":"","sets":""},"away":{"name":"Al Bahrain SC","score":"0","games":"","sets":""}},"timeElapsed":42,"fullTimeElapsed":{"hour":0,"min":0,"sec":0},"status":"KickOff","matchStatus":"KickOff"},{"eventTypeId":1,"eventId":27147141,"score":{"home":{"name":"La Union CF","score":"0","games":"","sets":""},"away":{"name":"FC Nordsjaelland","score":"1","games":"","sets":""}},"timeElapsed":40,"fullTimeElapsed":{"hour":0,"min":0,"sec":0},"status":"KickOff","matchStatus":"KickOff"},{"eventTypeId":1,"eventId":27147416,"score":{"home":{"name":"Dinamo Moscow","score":"2","games":"","sets":""},"away":{"name":"Dnipro","score":"0","games":"","sets":""}},"timeElapsed":44,"fullTimeElapsed":{"hour":0,"min":0,"sec":0},"status":"KickOff","matchStatus":"KickOff"}]

Open in new window

0
Comment
Question by:runnerjp2005
4 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39853599
That's JSON. Where is the XML?
0
 

Author Comment

by:runnerjp2005
ID: 39853618
Sorry my bad

<ScoresResponse xmlns="http://www.betfair.com/servicetypes/v1/InPlay/" debug="true">
<script id="FirebugLite" firebugIgnore="true" extension="Chrome"/>
<EventState>
<eventId>27144224</eventId>
<eventTypeId>1</eventTypeId>
<fullTimeElapsed>
<hour>0</hour>
<min>0</min>
<sec>0</sec>
</fullTimeElapsed>
<matchStatus>SecondHalfKickOff</matchStatus>
<status>SecondHalfKickOff</status>
<score>
<away>
<gameSequence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<games/>
<name>Stomil Olsztyn</name>
<score>0</score>
<sets/>
</away>
<home>
<gameSequence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<games/>
<name>Arka Gdynia</name>
<score>0</score>
<sets/>
</home>
</score>
<timeElapsed>77</timeElapsed>
</EventState>
<EventState>
<eventId>27147134</eventId>
<eventTypeId>1</eventTypeId>
<fullTimeElapsed>
<hour>0</hour>
<min>0</min>
<sec>0</sec>
</fullTimeElapsed>
<matchStatus>KickOff</matchStatus>
<status>KickOff</status>
<score>
<away>
<gameSequence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<games/>
<name>Al Tadamun Buri</name>
<score>1</score>
<sets/>
</away>
<home>
<gameSequence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<games/>
<name>Qalali Club</name>
<score>1</score>
<sets/>
</home>
</score>
<timeElapsed>46</timeElapsed>
</EventState>
<EventState>
<eventId>27147133</eventId>
<eventTypeId>1</eventTypeId>
<fullTimeElapsed>
<hour>0</hour>
<min>0</min>
<sec>0</sec>
</fullTimeElapsed>
<matchStatus>FirstHalfEnd</matchStatus>
<status>FirstHalfEnd</status>
<score>
<away>
<gameSequence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<games/>
<name>Al Bahrain SC</name>
<score>0</score>
<sets/>
</away>
<home>
<gameSequence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<games/>
<name>Al Ahli</name>
<score>0</score>
<sets/>
</home>
</score>
<timeElapsed>48</timeElapsed>
</EventState>
<EventState>
<eventId>27147141</eventId>
<eventTypeId>1</eventTypeId>
<fullTimeElapsed>
<hour>0</hour>
<min>0</min>
<sec>0</sec>
</fullTimeElapsed>
<matchStatus>FirstHalfEnd</matchStatus>
<status>FirstHalfEnd</status>
<score>
<away>
<gameSequence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<games/>
<name>FC Nordsjaelland</name>
<score>1</score>
<sets/>
</away>
<home>
<gameSequence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<games/>
<name>La Union CF</name>
<score>0</score>
<sets/>
</home>
</score>
<timeElapsed>46</timeElapsed>
</EventState>
<EventState>
<eventId>27147416</eventId>
<eventTypeId>1</eventTypeId>
<fullTimeElapsed>
<hour>0</hour>
<min>0</min>
<sec>0</sec>
</fullTimeElapsed>
<matchStatus>SecondHalfKickOff</matchStatus>
<status>SecondHalfKickOff</status>
<score>
<away>
<gameSequence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<games/>
<name>Dnipro</name>
<score>0</score>
<sets/>
</away>
<home>
<gameSequence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<games/>
<name>Dinamo Moscow</name>
<score>2</score>
<sets/>
</home>
</score>
<timeElapsed>46</timeElapsed>
</EventState>
</ScoresResponse>

Open in new window

0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 250 total points
ID: 39853619
There are multiple ways of reading XML files. Check following

http://www.codeproject.com/Articles/4826/XML-File-Parsing-in-VB-NET
0
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 250 total points
ID: 39854043
Hi runnerjp2005;

The following Linq to XML will return the needed information from the document.

' Load the XML document
Dim xdoc As XDocument = XDocument.Load("C:/Working Directory/ScoresResponse.xml")
' Get reference to root node
Dim xRoot As XElement = xdoc.Root
' Get the Namespace being used in the document
Dim ns As XNamespace = xRoot.Name.Namespace

' Query the document for the needed information.
Dim results = From es In xRoot.Descendants(ns + "EventState") _
              Select New With _
              { _
                  .HomeName = es.Element(ns + "score").Element(ns + "home").Element(ns + "name").Value, _
                  .HomeScore = es.Element(ns + "score").Element(ns + "home").Element(ns + "score").Value, _
                  .AwayName = es.Element(ns + "score").Element(ns + "away").Element(ns + "name").Value, _
                  .AwayScore = es.Element(ns + "score").Element(ns + "away").Element(ns + "score").Value, _
                  .TimeElapsed = es.Element(ns + "timeElapsed").Value _
              }

Open in new window

0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now