?
Solved

vb.net -> Reading xml file

Posted on 2014-02-12
4
Medium Priority
?
469 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 1000 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 1000 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

DFW AZURE MEETUP TONIGHT FRI 6PM

We will be discussing what Azure Stack is, how does it fit into the suit of offerings that Azure has currently, and where can it fit into your organizations technology stack. We will also be discussing limitations of the platform while covering various applicable scenarios.

Question has a verified solution.

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

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

770 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