Solved

vb.net -> Reading xml file

Posted on 2014-02-12
4
433 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 74

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

20 Experts available now in Live!

Get 1:1 Help Now