Solved

vb.net -> Reading xml file

Posted on 2014-02-12
4
467 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 63

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

695 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