473,671 Members | 2,163 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML and Direct Pathing to a node

Good afternoon, yes i am a newby so pls keep it simple.

Yesterday I started a small project where I have to make an API call and
receive back from that the long xml transcript down below.

Now, not knowing about XML I have experienced one or 2 issues.

Firstly, this is the code I have created to make the call and then extract a
few bits of information:

'Create the web request

Dim request As HttpWebRequest =
WebRequest.Crea te(https://api.games.betfair.com/rest/v...sername=******)
request.Method = "GET"
request.Timeout = 5000

'Add headers to the web request
request.Headers .Add("gamexAPIA gent", ********@hotmai l.co.uk.myGames .4.0)
request.Headers .Add("gamexAPIA gentInstance",
"0d69ee8290ee2f 9b336c1f060e349 7a5")
request.Headers .Add("gamexAPIP assword", "*******")

'Get response
Dim response As HttpWebResponse = request.GetResp onse()

Dim reader As StreamReader = New StreamReader(re sponse.GetRespo nseStream)
Dim objDoc As XmlReader = XmlReader.Creat e(reader)
objDoc.MoveToCo ntent()
objDoc.ReadToFo llowing("status ")
Me.StatusTextBo x.Text = objDoc.ReadElem entContentAsStr ing
objDoc.ReadToFo llowing("game")
Me.GameIDTextBo x.Text = objDoc.GetAttri bute("id").ToSt ring
objDoc.ReadToFo llowing("round" )
Me.RoundNumberT extBox.Text = objDoc.ReadElem entContentAsStr ing
objDoc.ReadToFo llowing("bettin gWindowPercenta geComplete")
Me.PercentageTi meTextBox.Text = objDoc.ReadElem entContentAsStr ing
CallLabel.Text = "captured"
Catch ex As Exception
CallLabel.Text = "not captured"
End Try

For the most part this works fine but what I would rather do, is point
directly to the nodes listed in the code directly, now I have some tell me
"//channelSnaphot/channel/status" is the way to go through a
XMLSelectSingle Node, but I have tried and failed using that method.

Is there anyone out the who can improve on my code so I can make 20 or 30
direct calls to the nodes in the Stream Response I receive below? I am
pleased to say the layout of the response will never change so thats not an
issue i need to address.

Regards

API Call Returns the following:
<channelSnapsho t>
<channel gameType="POKER " id="1444074" name="Exchange Poker Texas
Hold'em">
<status>RUNNING </status>
<game id="1817283">
<round>3</round>
<bettingWindowT ime>45</bettingWindowTi me>
<bettingWindowP ercentageComple te>24</bettingWindowPe rcentageComplet e>
<gameData>
<object name="Hand 1">
<description>On e Pair, Fours, Ace High,
with Q, 8 Kickers</description>
<status>IN_PLAY </status>
<property name="Card 1" value="20"/>
<property name="Card 2" value="29"/>
</object>
<object name="Hand 2">
<description>On e Pair, Sixes, Ace
High</description>
<status>IN_PLAY </status>
<property name="Card 1" value="5"/>
<property name="Card 2" value="44"/>
</object>
<object name="Hand 3">
<description>On e Pair, Fours, Ace High,
with Q, 6 Kickers</description>
<status>IN_PLAY </status>
<property name="Card 1" value="31"/>
<property name="Card 2" value="42"/>
</object>
<object name="Hand 4">
<description>Ac e High</description>
<status>IN_PLAY </status>
<property name="Card 1" value="49"/>
<property name="Card 2" value="45"/>
</object>
<object name="Community Cards">
<description/>
<status>N/A</status>
<property name="Card 1" value="3"/>
<property name="Card 2" value="13"/>
<property name="Card 3" value="11"/>
<property name="Card 4" value="NOT
AVAILABLE"/>
<property name="Card 5" value="NOT
AVAILABLE"/>
</object>
</gameData>
<markets currency="GBP">
<market id="5615051">
<status>ACTIV E</status>
<commissionRate >2.5</commissionRate>
<marketType>WIN _ONLY</marketType>
<selections type="MainBets" >
<selection id="658439">
<name>Hand 1</name>
<resource
href="https://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8439"
responseType="s electionTradeAc tivity" title="Trade Activity"/>
<status>IN_PLAY </status>
<amountMatched> 22.74</amountMatched>
<bestAvailableT oBackPrices>
<price
amountUnmatched ="204.42">6. 6</price>
<price
amountUnmatched ="381.64">6. 55</price>
<price
amountUnmatched ="576.92">6. 5</price>
</bestAvailableTo BackPrices>
<bestAvailableT oLayPrices>
<price
amountUnmatched ="74.6">6.7</price>
<price
amountUnmatched ="504.74">6. 75</price>
<price
amountUnmatched ="551.44">6. 8</price>
</bestAvailableTo LayPrices>
</selection>
<selection id="658440">
<name>Hand 2</name>
<resource
href="https://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8440"
responseType="s electionTradeAc tivity" title="Trade Activity"/>
<status>IN_PLAY </status>
<amountMatched> 88.68</amountMatched>
<bestAvailableT oBackPrices>
<price
amountUnmatched ="306.66">1. 72</price>
<price
amountUnmatched ="4127.36">1.71 </price>
<price
amountUnmatched ="59.63">1.7 </price>
</bestAvailableTo BackPrices>
<bestAvailableT oLayPrices>
<price
amountUnmatched ="99.98">1.7 3</price>
<price
amountUnmatched ="2188.96">1.74 </price>
<price
amountUnmatched ="2200.77">1.75 </price>
</bestAvailableTo LayPrices>
</selection>
<selection id="658441">
<name>Hand 3</name>
<resource
href="https://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8441"
responseType="s electionTradeAc tivity" title="Trade Activity"/>
<status>IN_PLAY </status>
<amountMatched> 102.9</amountMatched>
<bestAvailableT oBackPrices>
<price
amountUnmatched ="17.99">45. 0</price>
<price
amountUnmatched ="140.4">44. 5</price>
<price
amountUnmatched ="2.19">44.0 </price>
</bestAvailableTo BackPrices>
<bestAvailableT oLayPrices>
<price
amountUnmatched ="33.52">46. 0</price>
<price
amountUnmatched ="53.76">46. 5</price>
<price
amountUnmatched ="79.76">47. 0</price>
</bestAvailableTo LayPrices>
</selection>
<selection id="658442">
<name>Hand 4</name>
<resource
href="https://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8442"
responseType="s electionTradeAc tivity" title="Trade Activity"/>
<status>IN_PLAY </status>
<amountMatched> 1020.0</amountMatched>
<bestAvailableT oBackPrices>
<price
amountUnmatched ="158.07">4. 0</price>
<price
amountUnmatched ="198.19">3. 98</price>
<price
amountUnmatched ="631.28">3. 96</price>
</bestAvailableTo BackPrices>
<bestAvailableT oLayPrices>
<price
amountUnmatched ="103.84">4. 06</price>
<price
amountUnmatched ="612.72">4. 08</price>
<price
amountUnmatched ="914.6">4.1 </price>
</bestAvailableTo LayPrices>
</selection>
</selections>
</market>
</markets>
</game>
</channel>
</channelSnapshot >
Feb 21 '07 #1
21 1929
Again with the changing of it!!!!!!!

I DID NOT say:

objDoc.SelectSi ngleNode("//channelSnaphot/channel/status")

I DID say:

objDoc.SelectSi ngleNode("//channel/status")

I don't know why you persist in inserting channelSnaphot/ into the query!

//channel/status means find me the first element called status that is a
descendant of an element called channel that occurs anywhere in the
document.

"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
news:u%******** ********@TK2MSF TNGP06.phx.gbl. ..
Good afternoon, yes i am a newby so pls keep it simple.

Yesterday I started a small project where I have to make an API call and
receive back from that the long xml transcript down below.

Now, not knowing about XML I have experienced one or 2 issues.

Firstly, this is the code I have created to make the call and then extract
a few bits of information:

'Create the web request

Dim request As HttpWebRequest =
WebRequest.Crea te(https://api.games.betfair.com/rest/v...sername=******)
request.Method = "GET"
request.Timeout = 5000

'Add headers to the web request
request.Headers .Add("gamexAPIA gent", ********@hotmai l.co.uk.myGames .4.0)
request.Headers .Add("gamexAPIA gentInstance",
"0d69ee8290ee2f 9b336c1f060e349 7a5")
request.Headers .Add("gamexAPIP assword", "*******")

'Get response
Dim response As HttpWebResponse = request.GetResp onse()

Dim reader As StreamReader = New StreamReader(re sponse.GetRespo nseStream)
Dim objDoc As XmlReader = XmlReader.Creat e(reader)
objDoc.MoveToCo ntent()
objDoc.ReadToFo llowing("status ")
Me.StatusTextBo x.Text = objDoc.ReadElem entContentAsStr ing
objDoc.ReadToFo llowing("game")
Me.GameIDTextBo x.Text = objDoc.GetAttri bute("id").ToSt ring
objDoc.ReadToFo llowing("round" )
Me.RoundNumberT extBox.Text = objDoc.ReadElem entContentAsStr ing
objDoc.ReadToFo llowing("bettin gWindowPercenta geComplete")
Me.PercentageTi meTextBox.Text = objDoc.ReadElem entContentAsStr ing
CallLabel.Text = "captured"
Catch ex As Exception
CallLabel.Text = "not captured"
End Try

For the most part this works fine but what I would rather do, is point
directly to the nodes listed in the code directly, now I have some tell me
"//channelSnaphot/channel/status" is the way to go through a
XMLSelectSingle Node, but I have tried and failed using that method.

Is there anyone out the who can improve on my code so I can make 20 or 30
direct calls to the nodes in the Stream Response I receive below? I am
pleased to say the layout of the response will never change so thats not
an issue i need to address.

Regards

API Call Returns the following:
<channelSnapsho t>
<channel gameType="POKER " id="1444074" name="Exchange Poker Texas
Hold'em">
<status>RUNNING </status>
<game id="1817283">
<round>3</round>
<bettingWindowT ime>45</bettingWindowTi me>

<bettingWindowP ercentageComple te>24</bettingWindowPe rcentageComplet e>
<gameData>
<object name="Hand 1">
<description>On e Pair, Fours, Ace High,
with Q, 8 Kickers</description>
<status>IN_PLAY </status>
<property name="Card 1" value="20"/>
<property name="Card 2" value="29"/>
</object>
<object name="Hand 2">
<description>On e Pair, Sixes, Ace
High</description>
<status>IN_PLAY </status>
<property name="Card 1" value="5"/>
<property name="Card 2" value="44"/>
</object>
<object name="Hand 3">
<description>On e Pair, Fours, Ace High,
with Q, 6 Kickers</description>
<status>IN_PLAY </status>
<property name="Card 1" value="31"/>
<property name="Card 2" value="42"/>
</object>
<object name="Hand 4">
<description>Ac e High</description>
<status>IN_PLAY </status>
<property name="Card 1" value="49"/>
<property name="Card 2" value="45"/>
</object>
<object name="Community Cards">
<description/>
<status>N/A</status>
<property name="Card 1" value="3"/>
<property name="Card 2" value="13"/>
<property name="Card 3" value="11"/>
<property name="Card 4" value="NOT
AVAILABLE"/>
<property name="Card 5" value="NOT
AVAILABLE"/>
</object>
</gameData>
<markets currency="GBP">
<market id="5615051">
<status>ACTIV E</status>
<commissionRate >2.5</commissionRate>
<marketType>WIN _ONLY</marketType>
<selections type="MainBets" >
<selection id="658439">
<name>Hand 1</name>
<resource
href="https://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8439"
responseType="s electionTradeAc tivity" title="Trade Activity"/>
<status>IN_PLAY </status>

<amountMatched> 22.74</amountMatched>
<bestAvailableT oBackPrices>
<price
amountUnmatched ="204.42">6. 6</price>
<price
amountUnmatched ="381.64">6. 55</price>
<price
amountUnmatched ="576.92">6. 5</price>
</bestAvailableTo BackPrices>
<bestAvailableT oLayPrices>
<price
amountUnmatched ="74.6">6.7</price>
<price
amountUnmatched ="504.74">6. 75</price>
<price
amountUnmatched ="551.44">6. 8</price>
</bestAvailableTo LayPrices>
</selection>
<selection id="658440">
<name>Hand 2</name>
<resource
href="https://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8440"
responseType="s electionTradeAc tivity" title="Trade Activity"/>
<status>IN_PLAY </status>

<amountMatched> 88.68</amountMatched>
<bestAvailableT oBackPrices>
<price
amountUnmatched ="306.66">1. 72</price>
<price
amountUnmatched ="4127.36">1.71 </price>
<price
amountUnmatched ="59.63">1.7 </price>
</bestAvailableTo BackPrices>
<bestAvailableT oLayPrices>
<price
amountUnmatched ="99.98">1.7 3</price>
<price
amountUnmatched ="2188.96">1.74 </price>
<price
amountUnmatched ="2200.77">1.75 </price>
</bestAvailableTo LayPrices>
</selection>
<selection id="658441">
<name>Hand 3</name>
<resource
href="https://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8441"
responseType="s electionTradeAc tivity" title="Trade Activity"/>
<status>IN_PLAY </status>

<amountMatched> 102.9</amountMatched>
<bestAvailableT oBackPrices>
<price
amountUnmatched ="17.99">45. 0</price>
<price
amountUnmatched ="140.4">44. 5</price>
<price
amountUnmatched ="2.19">44.0 </price>
</bestAvailableTo BackPrices>
<bestAvailableT oLayPrices>
<price
amountUnmatched ="33.52">46. 0</price>
<price
amountUnmatched ="53.76">46. 5</price>
<price
amountUnmatched ="79.76">47. 0</price>
</bestAvailableTo LayPrices>
</selection>
<selection id="658442">
<name>Hand 4</name>
<resource
href="https://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8442"
responseType="s electionTradeAc tivity" title="Trade Activity"/>
<status>IN_PLAY </status>

<amountMatched> 1020.0</amountMatched>
<bestAvailableT oBackPrices>
<price
amountUnmatched ="158.07">4. 0</price>
<price
amountUnmatched ="198.19">3. 98</price>
<price
amountUnmatched ="631.28">3. 96</price>
</bestAvailableTo BackPrices>
<bestAvailableT oLayPrices>
<price
amountUnmatched ="103.84">4. 06</price>
<price
amountUnmatched ="612.72">4. 08</price>
<price
amountUnmatched ="914.6">4.1 </price>
</bestAvailableTo LayPrices>
</selection>
</selections>
</market>
</markets>
</game>
</channel>
</channelSnapshot >

Feb 21 '07 #2
And I did say, i have tried many variatons including yours but it did not
work

"Stephany Young" <noone@localhos twrote in message
news:Oq******** ******@TK2MSFTN GP02.phx.gbl...
Again with the changing of it!!!!!!!

I DID NOT say:

objDoc.SelectSi ngleNode("//channelSnaphot/channel/status")

I DID say:

objDoc.SelectSi ngleNode("//channel/status")

I don't know why you persist in inserting channelSnaphot/ into the query!

//channel/status means find me the first element called status that is a
descendant of an element called channel that occurs anywhere in the
document.

"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
news:u%******** ********@TK2MSF TNGP06.phx.gbl. ..
>Good afternoon, yes i am a newby so pls keep it simple.

Yesterday I started a small project where I have to make an API call and
receive back from that the long xml transcript down below.

Now, not knowing about XML I have experienced one or 2 issues.

Firstly, this is the code I have created to make the call and then
extract a few bits of information:

'Create the web request

Dim request As HttpWebRequest =
WebRequest.Cre ate(https://api.games.betfair.com/rest/v...sername=******)
request.Meth od = "GET"
request.Timeou t = 5000

'Add headers to the web request
request.Header s.Add("gamexAPI Agent", ********@hotmai l.co.uk.myGames .4.0)
request.Header s.Add("gamexAPI AgentInstance",
"0d69ee8290ee2 f9b336c1f060e34 97a5")
request.Header s.Add("gamexAPI Password", "*******")

'Get response
Dim response As HttpWebResponse = request.GetResp onse()

Dim reader As StreamReader = New StreamReader(re sponse.GetRespo nseStream)
Dim objDoc As XmlReader = XmlReader.Creat e(reader)
objDoc.MoveToC ontent()
objDoc.ReadToF ollowing("statu s")
Me.StatusTextB ox.Text = objDoc.ReadElem entContentAsStr ing
objDoc.ReadToF ollowing("game" )
Me.GameIDTextB ox.Text = objDoc.GetAttri bute("id").ToSt ring
objDoc.ReadToF ollowing("round ")
Me.RoundNumber TextBox.Text = objDoc.ReadElem entContentAsStr ing
objDoc.ReadToF ollowing("betti ngWindowPercent ageComplete")
Me.PercentageT imeTextBox.Text = objDoc.ReadElem entContentAsStr ing
CallLabel.Te xt = "captured"
Catch ex As Exception
CallLabel.Te xt = "not captured"
End Try

For the most part this works fine but what I would rather do, is point
directly to the nodes listed in the code directly, now I have some tell
me "//channelSnaphot/channel/status" is the way to go through a
XMLSelectSingl eNode, but I have tried and failed using that method.

Is there anyone out the who can improve on my code so I can make 20 or 30
direct calls to the nodes in the Stream Response I receive below? I am
pleased to say the layout of the response will never change so thats not
an issue i need to address.

Regards

API Call Returns the following:
<channelSnapsh ot>
<channel gameType="POKER " id="1444074" name="Exchange Poker Texas
Hold'em">
<status>RUNNING </status>
<game id="1817283">
<round>3</round>
<bettingWindowT ime>45</bettingWindowTi me>

<bettingWindow PercentageCompl ete>24</bettingWindowPe rcentageComplet e>
<gameData>
<object name="Hand 1">
<description>On e Pair, Fours, Ace High,
with Q, 8 Kickers</description>
<status>IN_PLAY </status>
<property name="Card 1" value="20"/>
<property name="Card 2" value="29"/>
</object>
<object name="Hand 2">
<description>On e Pair, Sixes, Ace
High</description>
<status>IN_PLAY </status>
<property name="Card 1" value="5"/>
<property name="Card 2" value="44"/>
</object>
<object name="Hand 3">
<description>On e Pair, Fours, Ace High,
with Q, 6 Kickers</description>
<status>IN_PLAY </status>
<property name="Card 1" value="31"/>
<property name="Card 2" value="42"/>
</object>
<object name="Hand 4">
<description>Ac e High</description>
<status>IN_PLAY </status>
<property name="Card 1" value="49"/>
<property name="Card 2" value="45"/>
</object>
<object name="Community Cards">
<description/>
<status>N/A</status>
<property name="Card 1" value="3"/>
<property name="Card 2" value="13"/>
<property name="Card 3" value="11"/>
<property name="Card 4" value="NOT
AVAILABLE"/>
<property name="Card 5" value="NOT
AVAILABLE"/>
</object>
</gameData>
<markets currency="GBP">
<market id="5615051">
<status>ACTIV E</status>
<commissionRate >2.5</commissionRate>
<marketType>WIN _ONLY</marketType>
<selections type="MainBets" >
<selection id="658439">
<name>Hand 1</name>
<resource
href="https://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8439"
responseType=" selectionTradeA ctivity" title="Trade Activity"/>
<status>IN_PLAY </status>

<amountMatched >22.74</amountMatched>
<bestAvailableT oBackPrices>
<price
amountUnmatche d="204.42">6. 6</price>
<price
amountUnmatche d="381.64">6.55 </price>
<price
amountUnmatche d="576.92">6. 5</price>
</bestAvailableTo BackPrices>
<bestAvailableT oLayPrices>
<price
amountUnmatche d="74.6">6.7</price>
<price
amountUnmatche d="504.74">6.75 </price>
<price
amountUnmatche d="551.44">6. 8</price>
</bestAvailableTo LayPrices>
</selection>
<selection id="658440">
<name>Hand 2</name>
<resource
href="https://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8440"
responseType=" selectionTradeA ctivity" title="Trade Activity"/>
<status>IN_PLAY </status>

<amountMatched >88.68</amountMatched>
<bestAvailableT oBackPrices>
<price
amountUnmatche d="306.66">1.72 </price>
<price
amountUnmatche d="4127.36">1.7 1</price>
<price
amountUnmatche d="59.63">1.7 </price>
</bestAvailableTo BackPrices>
<bestAvailableT oLayPrices>
<price
amountUnmatche d="99.98">1.7 3</price>
<price
amountUnmatche d="2188.96">1.7 4</price>
<price
amountUnmatche d="2200.77">1.7 5</price>
</bestAvailableTo LayPrices>
</selection>
<selection id="658441">
<name>Hand 3</name>
<resource
href="https://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8441"
responseType=" selectionTradeA ctivity" title="Trade Activity"/>
<status>IN_PLAY </status>

<amountMatched >102.9</amountMatched>
<bestAvailableT oBackPrices>
<price
amountUnmatche d="17.99">45. 0</price>
<price
amountUnmatche d="140.4">44. 5</price>
<price
amountUnmatche d="2.19">44.0 </price>
</bestAvailableTo BackPrices>
<bestAvailableT oLayPrices>
<price
amountUnmatche d="33.52">46. 0</price>
<price
amountUnmatche d="53.76">46. 5</price>
<price
amountUnmatche d="79.76">47. 0</price>
</bestAvailableTo LayPrices>
</selection>
<selection id="658442">
<name>Hand 4</name>
<resource
href="https://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8442"
responseType=" selectionTradeA ctivity" title="Trade Activity"/>
<status>IN_PLAY </status>

<amountMatched >1020.0</amountMatched>
<bestAvailableT oBackPrices>
<price
amountUnmatche d="158.07">4. 0</price>
<price
amountUnmatche d="198.19">3.98 </price>
<price
amountUnmatche d="631.28">3.96 </price>
</bestAvailableTo BackPrices>
<bestAvailableT oLayPrices>
<price
amountUnmatche d="103.84">4.06 </price>
<price
amountUnmatche d="612.72">4.08 </price>
<price
amountUnmatche d="914.6">4.1 </price>
</bestAvailableTo LayPrices>
</selection>
</selections>
</market>
</markets>
</game>
</channel>
</channelSnapshot >


Feb 21 '07 #3
Given the XML that you have provided, the following produces the results as
shown (I saved the XML to a file for the purpose of the exercise):

Dim _doc As New XmlDocument
_doc.Load("chan nelSnapshot.xml ")
Dim _node As XmlNode = _doc.SelectSing leNode("//channel/status")
Console.WriteLi ne(_node.InnerT ext)
_node = _doc.SelectSing leNode("//channel/game")
Console.WriteLi ne(_node.Attrib utes("id").Valu e)
_node = _doc.SelectSing leNode("//channel/game/round")
Console.WriteLi ne(_node.InnerT ext)
_node =
_doc.SelectSing leNode("//channel/game/bettingWindowPe rcentageComplet e")
Console.WriteLi ne(_node.InnerT ext)

Results
-------
RUNNING
1817283
3
24

If you change the XPath expressions or change the scope of the
SelectSingleNod e method, then it will not work.

Out of interest, what do you get if you execute the equivalent of:

Console.WriteLi ne(_doc.OuterXm l)

immediately after 'loading' the XmlDocument object from the StreamReader
object?
"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
And I did say, i have tried many variatons including yours but it did not
work

"Stephany Young" <noone@localhos twrote in message
news:Oq******** ******@TK2MSFTN GP02.phx.gbl...
>Again with the changing of it!!!!!!!

I DID NOT say:

objDoc.SelectSi ngleNode("//channelSnaphot/channel/status")

I DID say:

objDoc.SelectSi ngleNode("//channel/status")

I don't know why you persist in inserting channelSnaphot/ into the query!

//channel/status means find me the first element called status that is a
descendant of an element called channel that occurs anywhere in the
document.

"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
news:u%******* *********@TK2MS FTNGP06.phx.gbl ...
>>Good afternoon, yes i am a newby so pls keep it simple.

Yesterday I started a small project where I have to make an API call and
receive back from that the long xml transcript down below.

Now, not knowing about XML I have experienced one or 2 issues.

Firstly, this is the code I have created to make the call and then
extract a few bits of information:

'Create the web request

Dim request As HttpWebRequest =
WebRequest.Cr eate(https://api.games.betfair.com/rest/v...sername=******)
request.Metho d = "GET"
request.Timeo ut = 5000

'Add headers to the web request
request.Heade rs.Add("gamexAP IAgent", ********@hotmai l.co.uk.myGames .4.0)
request.Heade rs.Add("gamexAP IAgentInstance" ,
"0d69ee8290ee 2f9b336c1f060e3 497a5")
request.Heade rs.Add("gamexAP IPassword", "*******")

'Get response
Dim response As HttpWebResponse = request.GetResp onse()

Dim reader As StreamReader = New
StreamReader( response.GetRes ponseStream)
Dim objDoc As XmlReader = XmlReader.Creat e(reader)
objDoc.MoveTo Content()
objDoc.ReadTo Following("stat us")
Me.StatusText Box.Text = objDoc.ReadElem entContentAsStr ing
objDoc.ReadTo Following("game ")
Me.GameIDText Box.Text = objDoc.GetAttri bute("id").ToSt ring
objDoc.ReadTo Following("roun d")
Me.RoundNumbe rTextBox.Text = objDoc.ReadElem entContentAsStr ing
objDoc.ReadTo Following("bett ingWindowPercen tageComplete")
Me.Percentage TimeTextBox.Tex t = objDoc.ReadElem entContentAsStr ing
CallLabel.Tex t = "captured"
Catch ex As Exception
CallLabel.Tex t = "not captured"
End Try

For the most part this works fine but what I would rather do, is point
directly to the nodes listed in the code directly, now I have some tell
me "//channelSnaphot/channel/status" is the way to go through a
XMLSelectSing leNode, but I have tried and failed using that method.

Is there anyone out the who can improve on my code so I can make 20 or
30 direct calls to the nodes in the Stream Response I receive below? I
am pleased to say the layout of the response will never change so thats
not an issue i need to address.

Regards

API Call Returns the following:
<channelSnaps hot>
<channel gameType="POKER " id="1444074" name="Exchange Poker
Texas
Hold'em">
<status>RUNNING </status>
<game id="1817283">
<round>3</round>
<bettingWindowT ime>45</bettingWindowTi me>

<bettingWindo wPercentageComp lete>24</bettingWindowPe rcentageComplet e>
<gameData>
<object name="Hand 1">
<description>On e Pair, Fours, Ace High,
with Q, 8 Kickers</description>
<status>IN_PLAY </status>
<property name="Card 1" value="20"/>
<property name="Card 2" value="29"/>
</object>
<object name="Hand 2">
<description>On e Pair, Sixes, Ace
High</description>
<status>IN_PLAY </status>
<property name="Card 1" value="5"/>
<property name="Card 2" value="44"/>
</object>
<object name="Hand 3">
<description>On e Pair, Fours, Ace High,
with Q, 6 Kickers</description>
<status>IN_PLAY </status>
<property name="Card 1" value="31"/>
<property name="Card 2" value="42"/>
</object>
<object name="Hand 4">
<description>Ac e High</description>
<status>IN_PLAY </status>
<property name="Card 1" value="49"/>
<property name="Card 2" value="45"/>
</object>
<object name="Community Cards">
<description/>
<status>N/A</status>
<property name="Card 1" value="3"/>
<property name="Card 2" value="13"/>
<property name="Card 3" value="11"/>
<property name="Card 4" value="NOT
AVAILABLE"/>
<property name="Card 5" value="NOT
AVAILABLE"/>
</object>
</gameData>
<markets currency="GBP">
<market id="5615051">
<status>ACTIV E</status>
<commissionRate >2.5</commissionRate>
<marketType>WIN _ONLY</marketType>
<selections type="MainBets" >
<selection id="658439">
<name>Hand 1</name>
<resource
href="https ://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8439"
responseType= "selectionTrade Activity" title="Trade Activity"/>
<status>IN_PLAY </status>

<amountMatche d>22.74</amountMatched>
<bestAvailableT oBackPrices>
<price
amountUnmatch ed="204.42">6.6 </price>
<price
amountUnmatch ed="381.64">6.5 5</price>
<price
amountUnmatch ed="576.92">6.5 </price>
</bestAvailableTo BackPrices>
<bestAvailableT oLayPrices>
<price
amountUnmatch ed="74.6">6.7</price>
<price
amountUnmatch ed="504.74">6.7 5</price>
<price
amountUnmatch ed="551.44">6.8 </price>
</bestAvailableTo LayPrices>
</selection>
<selection id="658440">
<name>Hand 2</name>
<resource
href="https ://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8440"
responseType= "selectionTrade Activity" title="Trade Activity"/>
<status>IN_PLAY </status>

<amountMatche d>88.68</amountMatched>
<bestAvailableT oBackPrices>
<price
amountUnmatch ed="306.66">1.7 2</price>
<price
amountUnmatch ed="4127.36">1. 71</price>
<price
amountUnmatch ed="59.63">1.7 </price>
</bestAvailableTo BackPrices>
<bestAvailableT oLayPrices>
<price
amountUnmatch ed="99.98">1.73 </price>
<price
amountUnmatch ed="2188.96">1. 74</price>
<price
amountUnmatch ed="2200.77">1. 75</price>
</bestAvailableTo LayPrices>
</selection>
<selection id="658441">
<name>Hand 3</name>
<resource
href="https ://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8441"
responseType= "selectionTrade Activity" title="Trade Activity"/>
<status>IN_PLAY </status>

<amountMatche d>102.9</amountMatched>
<bestAvailableT oBackPrices>
<price
amountUnmatch ed="17.99">45.0 </price>
<price
amountUnmatch ed="140.4">44.5 </price>
<price
amountUnmatch ed="2.19">44.0 </price>
</bestAvailableTo BackPrices>
<bestAvailableT oLayPrices>
<price
amountUnmatch ed="33.52">46.0 </price>
<price
amountUnmatch ed="53.76">46.5 </price>
<price
amountUnmatch ed="79.76">47.0 </price>
</bestAvailableTo LayPrices>
</selection>
<selection id="658442">
<name>Hand 4</name>
<resource
href="https ://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8442"
responseType= "selectionTrade Activity" title="Trade Activity"/>
<status>IN_PLAY </status>

<amountMatche d>1020.0</amountMatched>
<bestAvailableT oBackPrices>
<price
amountUnmatch ed="158.07">4.0 </price>
<price
amountUnmatch ed="198.19">3.9 8</price>
<price
amountUnmatch ed="631.28">3.9 6</price>
</bestAvailableTo BackPrices>
<bestAvailableT oLayPrices>
<price
amountUnmatch ed="103.84">4.0 6</price>
<price
amountUnmatch ed="612.72">4.0 8</price>
<price
amountUnmatch ed="914.6">4.1 </price>
</bestAvailableTo LayPrices>
</selection>
</selections>
</market>
</markets>
</game>
</channel>
</channelSnapshot >


Feb 21 '07 #4
I get the following, sorry no formatting, when i put your code into my
program it still does not work so what am i missing?

<?xml version="1.0" encoding="UTF-8" standalone="yes "?>
<?xml-stylesheet type="text/xsl" href="/rest/apiStylesheet.x sl" ?>
<channelSnapsho t xmlns="urn:betf air:games:api:v 1">
<channel gameType="POKER " id="1444074" name="Exchange Poker Texas
Hold'em">
<status>RUNNING </status>
<game id="1823743">
<round>2</round>
<bettingWindowT ime>60</bettingWindowTi me>
<bettingWindowP ercentageComple te>25</bettingWindowPe rcentageComplet e>
<gameData>
<object name="Hand 1">
<description /><status>IN_PLA Y</status><propert y name="Card 1"
value="26" /><property name="Card 2" value="1" /></object><object name="Hand
2"><descript ion /><status>IN_PLA Y</status><propert y name="Card 1" value="22"
/><property name="Card 2" value="34" /></object><object name="Hand
3"><descript ion /><status>IN_PLA Y</status><propert y name="Card 1" value="7"
/><property name="Card 2" value="47" /></object><object name="Hand
4"><descript ion /><status>IN_PLA Y</status><propert y name="Card 1" value="39"
/><property name="Card 2" value="33" /></object><object name="Community
Cards"><descrip tion /><status>N/A</status><propert y name="Card 1" value="NOT
AVAILABLE" /><property name="Card 2" value="NOT AVAILABLE" /><property
name="Card 3" value="NOT AVAILABLE" /><property name="Card 4" value="NOT
AVAILABLE" /><property name="Card 5" value="NOT AVAILABLE"
/></object></gameData><marke ts currency="GBP"> <market
id="5627743"><s tatus>ACTIVE</status><commiss ionRate>2.5</commissionRate> <marketType>WIN _ONLY</marketType><sel ections
type="MainBets" ><selection id="658439"><na me>Hand 1</name><resource
href="https://api.games.betfa ir.com/rest/v1/selection/tradeActivity?u sername=kingten clubs&amp;marke tId=5627743&amp ;selectionId=65 8439"
responseType="s electionTradeAc tivity" title="Trade Activity"
/><status>IN_PLA Y</status><amountM atched>148.76</amountMatched>< bestAvailableTo BackPrices><pri ce
amountUnmatched ="146.29">4. 3</price><price
amountUnmatched ="785.42">4. 28</price><price
amountUnmatched ="880.28">4. 26</price></bestAvailableTo BackPrices><bes tAvailableToLay Prices><price
amountUnmatched ="62.16">4.3 4</price><price
amountUnmatched ="228.21">4. 36</price><price
amountUnmatched ="570.76">4. 38</price></bestAvailableTo LayPrices></selection><sele ction
id="658440"><na me>Hand 2</name><resource
href="https://api.games.betfa ir.com/rest/v1/selection/tradeActivity?u sername=kingten clubs&amp;marke tId=5627743&amp ;selectionId=65 8440"
responseType="s electionTradeAc tivity" title="Trade Activity"
/><status>IN_PLA Y</status><amountM atched>79.38</amountMatched>< bestAvailableTo BackPrices><pri ce
amountUnmatched ="263.15">2. 94</price><price
amountUnmatched ="1109.2">2. 93</price><price
amountUnmatched ="1288.64">2.91 </price></bestAvailableTo BackPrices><bes tAvailableToLay Prices><price
amountUnmatched ="183.92">2. 97</price><price
amountUnmatched ="294.17">2. 98</price><price
amountUnmatched ="836.12">2. 99</price></bestAvailableTo LayPrices></selection><sele ction
id="658441"><na me>Hand 3</name><resource
href="https://api.games.betfa ir.com/rest/v1/selection/tradeActivity?u sername=kingten clubs&amp;marke tId=5627743&amp ;selectionId=65 8441"
responseType="s electionTradeAc tivity" title="Trade Activity"
/><status>IN_PLA Y</status><amountM atched>173.92</amountMatched>< bestAvailableTo BackPrices><pri ce
amountUnmatched ="50.6">7.8</price><price
amountUnmatched ="447.26">7. 75</price><price
amountUnmatched ="487.0">7.7 </price></bestAvailableTo BackPrices><bes tAvailableToLay Prices><price
amountUnmatched ="169.6">7.9 </price><price
amountUnmatched ="314.44">7. 95</price><price
amountUnmatched ="468.72">8. 0</price></bestAvailableTo LayPrices></selection><sele ction
id="658442"><na me>Hand 4</name><resource
href="https://api.games.betfa ir.com/rest/v1/selection/tradeActivity?u sername=kingten clubs&amp;marke tId=5627743&amp ;selectionId=65 8442"
responseType="s electionTradeAc tivity" title="Trade Activity"
/><status>IN_PLA Y</status><amountM atched>131.4</amountMatched>< bestAvailableTo BackPrices><pri ce
amountUnmatched ="381.11">3. 28</price><price
amountUnmatched ="766.84">3. 26</price><price
amountUnmatched ="1157.4">3. 24</price></bestAvailableTo BackPrices><bes tAvailableToLay Prices><price
amountUnmatched ="230.47">3. 32</price><price
amountUnmatched ="973.0">3.3 4</price><price
amountUnmatched ="1116.04">3.36 </price></bestAvailableTo LayPrices></selection></selections></market></markets></game></channel></channelSnapshot >

"Stephany Young" <noone@localhos twrote in message
news:e%******** ********@TK2MSF TNGP04.phx.gbl. ..
Given the XML that you have provided, the following produces the results
as shown (I saved the XML to a file for the purpose of the exercise):

Dim _doc As New XmlDocument
_doc.Load("chan nelSnapshot.xml ")
Dim _node As XmlNode = _doc.SelectSing leNode("//channel/status")
Console.WriteLi ne(_node.InnerT ext)
_node = _doc.SelectSing leNode("//channel/game")
Console.WriteLi ne(_node.Attrib utes("id").Valu e)
_node = _doc.SelectSing leNode("//channel/game/round")
Console.WriteLi ne(_node.InnerT ext)
_node =
_doc.SelectSing leNode("//channel/game/bettingWindowPe rcentageComplet e")
Console.WriteLi ne(_node.InnerT ext)

Results
-------
RUNNING
1817283
3
24

If you change the XPath expressions or change the scope of the
SelectSingleNod e method, then it will not work.

Out of interest, what do you get if you execute the equivalent of:

Console.WriteLi ne(_doc.OuterXm l)

immediately after 'loading' the XmlDocument object from the StreamReader
object?
"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>And I did say, i have tried many variatons including yours but it did not
work

"Stephany Young" <noone@localhos twrote in message
news:Oq******* *******@TK2MSFT NGP02.phx.gbl.. .
>>Again with the changing of it!!!!!!!

I DID NOT say:

objDoc.SelectSi ngleNode("//channelSnaphot/channel/status")

I DID say:

objDoc.SelectSi ngleNode("//channel/status")

I don't know why you persist in inserting channelSnaphot/ into the
query!

//channel/status means find me the first element called status that is a
descendant of an element called channel that occurs anywhere in the
document.

"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
news:u%****** **********@TK2M SFTNGP06.phx.gb l...
Good afternoon, yes i am a newby so pls keep it simple.

Yesterday I started a small project where I have to make an API call
and receive back from that the long xml transcript down below.

Now, not knowing about XML I have experienced one or 2 issues.

Firstly, this is the code I have created to make the call and then
extract a few bits of information:

'Create the web request

Dim request As HttpWebRequest =
WebRequest.C reate(https://api.games.betfair.com/rest/v...sername=******)
request.Meth od = "GET"
request.Time out = 5000

'Add headers to the web request
request.Head ers.Add("gamexA PIAgent",
********@hot mail.co.uk.myGa mes.4.0)
request.Head ers.Add("gamexA PIAgentInstance ",
"0d69ee8290e e2f9b336c1f060e 3497a5")
request.Head ers.Add("gamexA PIPassword", "*******")

'Get response
Dim response As HttpWebResponse = request.GetResp onse()

Dim reader As StreamReader = New
StreamReader (response.GetRe sponseStream)
Dim objDoc As XmlReader = XmlReader.Creat e(reader)
objDoc.MoveT oContent()
objDoc.ReadT oFollowing("sta tus")
Me.StatusTex tBox.Text = objDoc.ReadElem entContentAsStr ing
objDoc.ReadT oFollowing("gam e")
Me.GameIDTex tBox.Text = objDoc.GetAttri bute("id").ToSt ring
objDoc.ReadT oFollowing("rou nd")
Me.RoundNumb erTextBox.Text = objDoc.ReadElem entContentAsStr ing
objDoc.ReadT oFollowing("bet tingWindowPerce ntageComplete")
Me.Percentag eTimeTextBox.Te xt = objDoc.ReadElem entContentAsStr ing
CallLabel.Te xt = "captured"
Catch ex As Exception
CallLabel.Te xt = "not captured"
End Try

For the most part this works fine but what I would rather do, is point
directly to the nodes listed in the code directly, now I have some tell
me "//channelSnaphot/channel/status" is the way to go through a
XMLSelectSin gleNode, but I have tried and failed using that method.

Is there anyone out the who can improve on my code so I can make 20 or
30 direct calls to the nodes in the Stream Response I receive below? I
am pleased to say the layout of the response will never change so thats
not an issue i need to address.

Regards

API Call Returns the following:
<channelSnap shot>
<channel gameType="POKER " id="1444074" name="Exchange Poker
Texas
Hold'em">
<status>RUNNING </status>
<game id="1817283">
<round>3</round>
<bettingWindowT ime>45</bettingWindowTi me>

<bettingWind owPercentageCom plete>24</bettingWindowPe rcentageComplet e>
<gameData>
<object name="Hand 1">
<description>On e Pair, Fours, Ace High,
with Q, 8 Kickers</description>
<status>IN_PLAY </status>
<property name="Card 1" value="20"/>
<property name="Card 2" value="29"/>
</object>
<object name="Hand 2">
<description>On e Pair, Sixes, Ace
High</description>
<status>IN_PLAY </status>
<property name="Card 1" value="5"/>
<property name="Card 2" value="44"/>
</object>
<object name="Hand 3">
<description>On e Pair, Fours, Ace High,
with Q, 6 Kickers</description>
<status>IN_PLAY </status>
<property name="Card 1" value="31"/>
<property name="Card 2" value="42"/>
</object>
<object name="Hand 4">
<description>Ac e High</description>
<status>IN_PLAY </status>
<property name="Card 1" value="49"/>
<property name="Card 2" value="45"/>
</object>
<object name="Community Cards">
<description/>
<status>N/A</status>
<property name="Card 1" value="3"/>
<property name="Card 2" value="13"/>
<property name="Card 3" value="11"/>
<property name="Card 4" value="NOT
AVAILABLE"/>
<property name="Card 5" value="NOT
AVAILABLE"/>
</object>
</gameData>
<markets currency="GBP">
<market id="5615051">
<status>ACTIV E</status>
<commissionRate >2.5</commissionRate>
<marketType>WIN _ONLY</marketType>
<selections type="MainBets" >
<selection id="658439">
<name>Hand 1</name>
<resource
href="http s://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8439"
responseType ="selectionTrad eActivity" title="Trade Activity"/>
<status>IN_PLAY </status>

<amountMatch ed>22.74</amountMatched>
<bestAvailableT oBackPrices>
<price
amountUnmatc hed="204.42">6. 6</price>
<price
amountUnmatc hed="381.64">6. 55</price>
<price
amountUnmatc hed="576.92">6. 5</price>

</bestAvailableTo BackPrices>
<bestAvailableT oLayPrices>
<price
amountUnmatc hed="74.6">6.7</price>
<price
amountUnmatc hed="504.74">6. 75</price>
<price
amountUnmatc hed="551.44">6. 8</price>
</bestAvailableTo LayPrices>
</selection>
<selection id="658440">
<name>Hand 2</name>
<resource
href="http s://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8440"
responseType ="selectionTrad eActivity" title="Trade Activity"/>
<status>IN_PLAY </status>

<amountMatch ed>88.68</amountMatched>
<bestAvailableT oBackPrices>
<price
amountUnmatc hed="306.66">1. 72</price>
<price
amountUnmatc hed="4127.36">1 .71</price>
<price
amountUnmatc hed="59.63">1.7 </price>

</bestAvailableTo BackPrices>
<bestAvailableT oLayPrices>
<price
amountUnmatc hed="99.98">1.7 3</price>
<price
amountUnmatc hed="2188.96">1 .74</price>
<price
amountUnmatc hed="2200.77">1 .75</price>
</bestAvailableTo LayPrices>
</selection>
<selection id="658441">
<name>Hand 3</name>
<resource
href="http s://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8441"
responseType ="selectionTrad eActivity" title="Trade Activity"/>
<status>IN_PLAY </status>

<amountMatch ed>102.9</amountMatched>
<bestAvailableT oBackPrices>
<price
amountUnmatc hed="17.99">45. 0</price>
<price
amountUnmatc hed="140.4">44. 5</price>
<price
amountUnmatc hed="2.19">44.0 </price>

</bestAvailableTo BackPrices>
<bestAvailableT oLayPrices>
<price
amountUnmatc hed="33.52">46. 0</price>
<price
amountUnmatc hed="53.76">46. 5</price>
<price
amountUnmatc hed="79.76">47. 0</price>
</bestAvailableTo LayPrices>
</selection>
<selection id="658442">
<name>Hand 4</name>
<resource
href="http s://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8442"
responseType ="selectionTrad eActivity" title="Trade Activity"/>
<status>IN_PLAY </status>

<amountMatch ed>1020.0</amountMatched>
<bestAvailableT oBackPrices>
<price
amountUnmatc hed="158.07">4. 0</price>
<price
amountUnmatc hed="198.19">3. 98</price>
<price
amountUnmatc hed="631.28">3. 96</price>

</bestAvailableTo BackPrices>
<bestAvailableT oLayPrices>
<price
amountUnmatc hed="103.84">4. 06</price>
<price
amountUnmatc hed="612.72">4. 08</price>
<price
amountUnmatc hed="914.6">4.1 </price>
</bestAvailableTo LayPrices>
</selection>
</selections>
</market>
</markets>
</game>
</channel>
</channelSnapshot >


Feb 21 '07 #5
OK ...

What results do you get as you interrogate each node?

If you get exceptions then please post the full exception information.

"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
news:Oq******** ******@TK2MSFTN GP02.phx.gbl...
>I get the following, sorry no formatting, when i put your code into my
program it still does not work so what am i missing?

<?xml version="1.0" encoding="UTF-8" standalone="yes "?>
<?xml-stylesheet type="text/xsl" href="/rest/apiStylesheet.x sl" ?>
<channelSnapsho t xmlns="urn:betf air:games:api:v 1">
<channel gameType="POKER " id="1444074" name="Exchange Poker Texas
Hold'em">
<status>RUNNING </status>
<game id="1823743">
<round>2</round>
<bettingWindowT ime>60</bettingWindowTi me>
<bettingWindowP ercentageComple te>25</bettingWindowPe rcentageComplet e>
<gameData>
<object name="Hand 1">
<description /><status>IN_PLA Y</status><propert y name="Card 1"
value="26" /><property name="Card 2" value="1" /></object><object
name="Hand 2"><descript ion /><status>IN_PLA Y</status><propert y name="Card
1" value="22" /><property name="Card 2" value="34" /></object><object
name="Hand 3"><descript ion /><status>IN_PLA Y</status><propert y name="Card
1" value="7" /><property name="Card 2" value="47" /></object><object
name="Hand 4"><descript ion /><status>IN_PLA Y</status><propert y name="Card
1" value="39" /><property name="Card 2" value="33" /></object><object
name="Community Cards"><descrip tion /><status>N/A</status><propert y
name="Card 1" value="NOT AVAILABLE" /><property name="Card 2" value="NOT
AVAILABLE" /><property name="Card 3" value="NOT AVAILABLE" /><property
name="Card 4" value="NOT AVAILABLE" /><property name="Card 5" value="NOT
AVAILABLE" /></object></gameData><marke ts currency="GBP"> <market
id="5627743"><s tatus>ACTIVE</status><commiss ionRate>2.5</commissionRate> <marketType>WIN _ONLY</marketType><sel ections
type="MainBets" ><selection id="658439"><na me>Hand 1</name><resource
href="https://api.games.betfa ir.com/rest/v1/selection/tradeActivity?u sername=kingten clubs&amp;marke tId=5627743&amp ;selectionId=65 8439"
responseType="s electionTradeAc tivity" title="Trade Activity"
/><status>IN_PLA Y</status><amountM atched>148.76</amountMatched>< bestAvailableTo BackPrices><pri ce
amountUnmatched ="146.29">4. 3</price><price
amountUnmatched ="785.42">4. 28</price><price
amountUnmatched ="880.28">4. 26</price></bestAvailableTo BackPrices><bes tAvailableToLay Prices><price
amountUnmatched ="62.16">4.3 4</price><price
amountUnmatched ="228.21">4. 36</price><price
amountUnmatched ="570.76">4. 38</price></bestAvailableTo LayPrices></selection><sele ction
id="658440"><na me>Hand 2</name><resource
href="https://api.games.betfa ir.com/rest/v1/selection/tradeActivity?u sername=kingten clubs&amp;marke tId=5627743&amp ;selectionId=65 8440"
responseType="s electionTradeAc tivity" title="Trade Activity"
/><status>IN_PLA Y</status><amountM atched>79.38</amountMatched>< bestAvailableTo BackPrices><pri ce
amountUnmatched ="263.15">2. 94</price><price
amountUnmatched ="1109.2">2. 93</price><price
amountUnmatched ="1288.64">2.91 </price></bestAvailableTo BackPrices><bes tAvailableToLay Prices><price
amountUnmatched ="183.92">2. 97</price><price
amountUnmatched ="294.17">2. 98</price><price
amountUnmatched ="836.12">2. 99</price></bestAvailableTo LayPrices></selection><sele ction
id="658441"><na me>Hand 3</name><resource
href="https://api.games.betfa ir.com/rest/v1/selection/tradeActivity?u sername=kingten clubs&amp;marke tId=5627743&amp ;selectionId=65 8441"
responseType="s electionTradeAc tivity" title="Trade Activity"
/><status>IN_PLA Y</status><amountM atched>173.92</amountMatched>< bestAvailableTo BackPrices><pri ce
amountUnmatched ="50.6">7.8</price><price
amountUnmatched ="447.26">7. 75</price><price
amountUnmatched ="487.0">7.7 </price></bestAvailableTo BackPrices><bes tAvailableToLay Prices><price
amountUnmatched ="169.6">7.9 </price><price
amountUnmatched ="314.44">7. 95</price><price
amountUnmatched ="468.72">8. 0</price></bestAvailableTo LayPrices></selection><sele ction
id="658442"><na me>Hand 4</name><resource
href="https://api.games.betfa ir.com/rest/v1/selection/tradeActivity?u sername=kingten clubs&amp;marke tId=5627743&amp ;selectionId=65 8442"
responseType="s electionTradeAc tivity" title="Trade Activity"
/><status>IN_PLA Y</status><amountM atched>131.4</amountMatched>< bestAvailableTo BackPrices><pri ce
amountUnmatched ="381.11">3. 28</price><price
amountUnmatched ="766.84">3. 26</price><price
amountUnmatched ="1157.4">3. 24</price></bestAvailableTo BackPrices><bes tAvailableToLay Prices><price
amountUnmatched ="230.47">3. 32</price><price
amountUnmatched ="973.0">3.3 4</price><price
amountUnmatched ="1116.04">3.36 </price></bestAvailableTo LayPrices></selection></selections></market></markets></game></channel></channelSnapshot >

"Stephany Young" <noone@localhos twrote in message
news:e%******** ********@TK2MSF TNGP04.phx.gbl. ..
>Given the XML that you have provided, the following produces the results
as shown (I saved the XML to a file for the purpose of the exercise):

Dim _doc As New XmlDocument
_doc.Load("chan nelSnapshot.xml ")
Dim _node As XmlNode = _doc.SelectSing leNode("//channel/status")
Console.WriteLi ne(_node.InnerT ext)
_node = _doc.SelectSing leNode("//channel/game")
Console.WriteLi ne(_node.Attrib utes("id").Valu e)
_node = _doc.SelectSing leNode("//channel/game/round")
Console.WriteLi ne(_node.InnerT ext)
_node =
_doc.SelectSin gleNode("//channel/game/bettingWindowPe rcentageComplet e")
Console.WriteLi ne(_node.InnerT ext)

Results
-------
RUNNING
1817283
3
24

If you change the XPath expressions or change the scope of the
SelectSingleNo de method, then it will not work.

Out of interest, what do you get if you execute the equivalent of:

Console.WriteLi ne(_doc.OuterXm l)

immediately after 'loading' the XmlDocument object from the StreamReader
object?
"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
news:%2******* *********@TK2MS FTNGP04.phx.gbl ...
>>And I did say, i have tried many variatons including yours but it did
not work

"Stephany Young" <noone@localhos twrote in message
news:Oq****** ********@TK2MSF TNGP02.phx.gbl. ..
Again with the changing of it!!!!!!!

I DID NOT say:

objDoc.SelectSi ngleNode("//channelSnaphot/channel/status")

I DID say:

objDoc.SelectSi ngleNode("//channel/status")

I don't know why you persist in inserting channelSnaphot/ into the
query!

//channel/status means find me the first element called status that is
a descendant of an element called channel that occurs anywhere in the
document.

"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
news:u%***** ***********@TK2 MSFTNGP06.phx.g bl...
Good afternoon, yes i am a newby so pls keep it simple.
>
Yesterday I started a small project where I have to make an API call
and receive back from that the long xml transcript down below.
>
Now, not knowing about XML I have experienced one or 2 issues.
>
Firstly, this is the code I have created to make the call and then
extract a few bits of information:
>
'Create the web request
>
Dim request As HttpWebRequest =
WebRequest. Create(https://api.games.betfair.com/rest/v...sername=******)
request.Met hod = "GET"
request.Tim eout = 5000
>
'Add headers to the web request
request.Hea ders.Add("gamex APIAgent",
********@ho tmail.co.uk.myG ames.4.0)
request.Hea ders.Add("gamex APIAgentInstanc e",
"0d69ee8290 ee2f9b336c1f060 e3497a5")
request.Hea ders.Add("gamex APIPassword", "*******")
>
'Get response
Dim response As HttpWebResponse = request.GetResp onse()
>
Dim reader As StreamReader = New
StreamReade r(response.GetR esponseStream)
Dim objDoc As XmlReader = XmlReader.Creat e(reader)
objDoc.Move ToContent()
objDoc.Read ToFollowing("st atus")
Me.StatusTe xtBox.Text = objDoc.ReadElem entContentAsStr ing
objDoc.Read ToFollowing("ga me")
Me.GameIDTe xtBox.Text = objDoc.GetAttri bute("id").ToSt ring
objDoc.Read ToFollowing("ro und")
Me.RoundNum berTextBox.Text = objDoc.ReadElem entContentAsStr ing
objDoc.Read ToFollowing("be ttingWindowPerc entageComplete" )
Me.Percenta geTimeTextBox.T ext = objDoc.ReadElem entContentAsStr ing
CallLabel.T ext = "captured"
Catch ex As Exception
CallLabel.T ext = "not captured"
End Try
>
For the most part this works fine but what I would rather do, is point
directly to the nodes listed in the code directly, now I have some
tell me "//channelSnaphot/channel/status" is the way to go through a
XMLSelectSi ngleNode, but I have tried and failed using that method.
>
Is there anyone out the who can improve on my code so I can make 20 or
30 direct calls to the nodes in the Stream Response I receive below? I
am pleased to say the layout of the response will never change so
thats not an issue i need to address.
>
Regards
>
API Call Returns the following:
<channelSna pshot>
<channel gameType="POKER " id="1444074" name="Exchange Poker
Texas
Hold'em">
<status>RUNNING </status>
<game id="1817283">
<round>3</round>
<bettingWindowT ime>45</bettingWindowTi me>
>
<bettingWin dowPercentageCo mplete>24</bettingWindowPe rcentageComplet e>
<gameData>
<object name="Hand 1">
<description>On e Pair, Fours, Ace
High,
with Q, 8 Kickers</description>
<status>IN_PLAY </status>
<property name="Card 1" value="20"/>
<property name="Card 2" value="29"/>
</object>
<object name="Hand 2">
<description>On e Pair, Sixes, Ace
High</description>
<status>IN_PLAY </status>
<property name="Card 1" value="5"/>
<property name="Card 2" value="44"/>
</object>
<object name="Hand 3">
<description>On e Pair, Fours, Ace
High,
with Q, 6 Kickers</description>
<status>IN_PLAY </status>
<property name="Card 1" value="31"/>
<property name="Card 2" value="42"/>
</object>
<object name="Hand 4">
<description>Ac e High</description>
<status>IN_PLAY </status>
<property name="Card 1" value="49"/>
<property name="Card 2" value="45"/>
</object>
<object name="Community Cards">
<description/>
<status>N/A</status>
<property name="Card 1" value="3"/>
<property name="Card 2" value="13"/>
<property name="Card 3" value="11"/>
<property name="Card 4" value="NOT
AVAILABLE "/>
<property name="Card 5" value="NOT
AVAILABLE "/>
</object>
</gameData>
<markets currency="GBP">
<market id="5615051">
<status>ACTIV E</status>
<commissionRate >2.5</commissionRate>
<marketType>WIN _ONLY</marketType>
<selections type="MainBets" >
<selection id="658439">
<name>Hand 1</name>
<resource
href="https ://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8439"
responseTyp e="selectionTra deActivity" title="Trade Activity"/>
<status>IN_PLAY </status>
>
<amountMatc hed>22.74</amountMatched>
>
<bestAvaila bleToBackPrices >
<price
amountUnmat ched="204.42">6 .6</price>
<price
amountUnmat ched="381.64">6 .55</price>
<price
amountUnmat ched="576.92">6 .5</price>
>
</bestAvailableTo BackPrices>
<bestAvailableT oLayPrices>
<price
amountUnmat ched="74.6">6.7 </price>
<price
amountUnmat ched="504.74">6 .75</price>
<price
amountUnmat ched="551.44">6 .8</price>
>
</bestAvailableTo LayPrices>
</selection>
<selection id="658440">
<name>Hand 2</name>
<resource
href="https ://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8440"
responseTyp e="selectionTra deActivity" title="Trade Activity"/>
<status>IN_PLAY </status>
>
<amountMatc hed>88.68</amountMatched>
>
<bestAvaila bleToBackPrices >
<price
amountUnmat ched="306.66">1 .72</price>
<price
amountUnmat ched="4127.36"> 1.71</price>
<price
amountUnmat ched="59.63">1. 7</price>
>
</bestAvailableTo BackPrices>
<bestAvailableT oLayPrices>
<price
amountUnmat ched="99.98">1. 73</price>
<price
amountUnmat ched="2188.96"> 1.74</price>
<price
amountUnmat ched="2200.77"> 1.75</price>
>
</bestAvailableTo LayPrices>
</selection>
<selection id="658441">
<name>Hand 3</name>
<resource
href="https ://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8441"
responseTyp e="selectionTra deActivity" title="Trade Activity"/>
<status>IN_PLAY </status>
>
<amountMatc hed>102.9</amountMatched>
>
<bestAvaila bleToBackPrices >
<price
amountUnmat ched="17.99">45 .0</price>
<price
amountUnmat ched="140.4">44 .5</price>
<price
amountUnmat ched="2.19">44. 0</price>
>
</bestAvailableTo BackPrices>
<bestAvailableT oLayPrices>
<price
amountUnmat ched="33.52">46 .0</price>
<price
amountUnmat ched="53.76">46 .5</price>
<price
amountUnmat ched="79.76">47 .0</price>
>
</bestAvailableTo LayPrices>
</selection>
<selection id="658442">
<name>Hand 4</name>
<resource
href="https ://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8442"
responseTyp e="selectionTra deActivity" title="Trade Activity"/>
<status>IN_PLAY </status>
>
<amountMatc hed>1020.0</amountMatched>
>
<bestAvaila bleToBackPrices >
<price
amountUnmat ched="158.07">4 .0</price>
<price
amountUnmat ched="198.19">3 .98</price>
<price
amountUnmat ched="631.28">3 .96</price>
>
</bestAvailableTo BackPrices>
<bestAvailableT oLayPrices>
<price
amountUnmat ched="103.84">4 .06</price>
<price
amountUnmat ched="612.72">4 .08</price>
<price
amountUnmat ched="914.6">4. 1</price>
>
</bestAvailableTo LayPrices>
</selection>
</selections>
</market>
</markets>
</game>
</channel>
</channelSnapshot >
>
>

Feb 21 '07 #6
The err.description says Object reference not set to an instance of an
object.

"Stephany Young" <noone@localhos twrote in message
news:Os******** ******@TK2MSFTN GP04.phx.gbl...
OK ...

What results do you get as you interrogate each node?

If you get exceptions then please post the full exception information.

"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
news:Oq******** ******@TK2MSFTN GP02.phx.gbl...
>>I get the following, sorry no formatting, when i put your code into my
program it still does not work so what am i missing?

<?xml version="1.0" encoding="UTF-8" standalone="yes "?>
<?xml-stylesheet type="text/xsl" href="/rest/apiStylesheet.x sl" ?>
<channelSnapsh ot xmlns="urn:betf air:games:api:v 1">
<channel gameType="POKER " id="1444074" name="Exchange Poker Texas
Hold'em">
<status>RUNNING </status>
<game id="1823743">
<round>2</round>
<bettingWindowT ime>60</bettingWindowTi me>
<bettingWindowP ercentageComple te>25</bettingWindowPe rcentageComplet e>
<gameData>
<object name="Hand 1">
<description /><status>IN_PLA Y</status><propert y name="Card 1"
value="26" /><property name="Card 2" value="1" /></object><object
name="Hand 2"><descript ion /><status>IN_PLA Y</status><propert y name="Card
1" value="22" /><property name="Card 2" value="34" /></object><object
name="Hand 3"><descript ion /><status>IN_PLA Y</status><propert y name="Card
1" value="7" /><property name="Card 2" value="47" /></object><object
name="Hand 4"><descript ion /><status>IN_PLA Y</status><propert y name="Card
1" value="39" /><property name="Card 2" value="33" /></object><object
name="Communit y Cards"><descrip tion /><status>N/A</status><propert y
name="Card 1" value="NOT AVAILABLE" /><property name="Card 2" value="NOT
AVAILABLE" /><property name="Card 3" value="NOT AVAILABLE" /><property
name="Card 4" value="NOT AVAILABLE" /><property name="Card 5" value="NOT
AVAILABLE" /></object></gameData><marke ts currency="GBP"> <market
id="5627743">< status>ACTIVE</status><commiss ionRate>2.5</commissionRate> <marketType>WIN _ONLY</marketType><sel ections
type="MainBets "><selectio n id="658439"><na me>Hand 1</name><resource
href="https://api.games.betfa ir.com/rest/v1/selection/tradeActivity?u sername=kingten clubs&amp;marke tId=5627743&amp ;selectionId=65 8439"
responseType=" selectionTradeA ctivity" title="Trade Activity"
/><status>IN_PLA Y</status><amountM atched>148.76</amountMatched>< bestAvailableTo BackPrices><pri ce
amountUnmatche d="146.29">4. 3</price><price
amountUnmatche d="785.42">4.28 </price><price
amountUnmatche d="880.28">4.26 </price></bestAvailableTo BackPrices><bes tAvailableToLay Prices><price
amountUnmatche d="62.16">4.3 4</price><price
amountUnmatche d="228.21">4.36 </price><price
amountUnmatche d="570.76">4.38 </price></bestAvailableTo LayPrices></selection><sele ction
id="658440"><n ame>Hand 2</name><resource
href="https://api.games.betfa ir.com/rest/v1/selection/tradeActivity?u sername=kingten clubs&amp;marke tId=5627743&amp ;selectionId=65 8440"
responseType=" selectionTradeA ctivity" title="Trade Activity"
/><status>IN_PLA Y</status><amountM atched>79.38</amountMatched>< bestAvailableTo BackPrices><pri ce
amountUnmatche d="263.15">2.94 </price><price
amountUnmatche d="1109.2">2.93 </price><price
amountUnmatche d="1288.64">2.9 1</price></bestAvailableTo BackPrices><bes tAvailableToLay Prices><price
amountUnmatche d="183.92">2.97 </price><price
amountUnmatche d="294.17">2.98 </price><price
amountUnmatche d="836.12">2.99 </price></bestAvailableTo LayPrices></selection><sele ction
id="658441"><n ame>Hand 3</name><resource
href="https://api.games.betfa ir.com/rest/v1/selection/tradeActivity?u sername=kingten clubs&amp;marke tId=5627743&amp ;selectionId=65 8441"
responseType=" selectionTradeA ctivity" title="Trade Activity"
/><status>IN_PLA Y</status><amountM atched>173.92</amountMatched>< bestAvailableTo BackPrices><pri ce
amountUnmatche d="50.6">7.8</price><price
amountUnmatche d="447.26">7.75 </price><price
amountUnmatche d="487.0">7.7 </price></bestAvailableTo BackPrices><bes tAvailableToLay Prices><price
amountUnmatche d="169.6">7.9 </price><price
amountUnmatche d="314.44">7.95 </price><price
amountUnmatche d="468.72">8. 0</price></bestAvailableTo LayPrices></selection><sele ction
id="658442"><n ame>Hand 4</name><resource
href="https://api.games.betfa ir.com/rest/v1/selection/tradeActivity?u sername=kingten clubs&amp;marke tId=5627743&amp ;selectionId=65 8442"
responseType=" selectionTradeA ctivity" title="Trade Activity"
/><status>IN_PLA Y</status><amountM atched>131.4</amountMatched>< bestAvailableTo BackPrices><pri ce
amountUnmatche d="381.11">3.28 </price><price
amountUnmatche d="766.84">3.26 </price><price
amountUnmatche d="1157.4">3.24 </price></bestAvailableTo BackPrices><bes tAvailableToLay Prices><price
amountUnmatche d="230.47">3.32 </price><price
amountUnmatche d="973.0">3.3 4</price><price
amountUnmatche d="1116.04">3.3 6</price></bestAvailableTo LayPrices></selection></selections></market></markets></game></channel></channelSnapshot >

"Stephany Young" <noone@localhos twrote in message
news:e%******* *********@TK2MS FTNGP04.phx.gbl ...
>>Given the XML that you have provided, the following produces the results
as shown (I saved the XML to a file for the purpose of the exercise):

Dim _doc As New XmlDocument
_doc.Load("chan nelSnapshot.xml ")
Dim _node As XmlNode = _doc.SelectSing leNode("//channel/status")
Console.WriteLi ne(_node.InnerT ext)
_node = _doc.SelectSing leNode("//channel/game")
Console.WriteLi ne(_node.Attrib utes("id").Valu e)
_node = _doc.SelectSing leNode("//channel/game/round")
Console.WriteLi ne(_node.InnerT ext)
_node =
_doc.SelectSi ngleNode("//channel/game/bettingWindowPe rcentageComplet e")
Console.WriteLi ne(_node.InnerT ext)

Results
-------
RUNNING
1817283
3
24

If you change the XPath expressions or change the scope of the
SelectSingleN ode method, then it will not work.

Out of interest, what do you get if you execute the equivalent of:

Console.WriteLi ne(_doc.OuterXm l)

immediately after 'loading' the XmlDocument object from the StreamReader
object?
"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
news:%2****** **********@TK2M SFTNGP04.phx.gb l...
And I did say, i have tried many variatons including yours but it did
not work

"Stephany Young" <noone@localhos twrote in message
news:Oq***** *********@TK2MS FTNGP02.phx.gbl ...
Again with the changing of it!!!!!!!
>
I DID NOT say:
>
objDoc.SelectSi ngleNode("//channelSnaphot/channel/status")
>
I DID say:
>
objDoc.SelectSi ngleNode("//channel/status")
>
I don't know why you persist in inserting channelSnaphot/ into the
query!
>
//channel/status means find me the first element called status that is
a descendant of an element called channel that occurs anywhere in the
document.
>
>
>
"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
news:u%**** ************@TK 2MSFTNGP06.phx. gbl...
>Good afternoon, yes i am a newby so pls keep it simple.
>>
>Yesterda y I started a small project where I have to make an API call
>and receive back from that the long xml transcript down below.
>>
>Now, not knowing about XML I have experienced one or 2 issues.
>>
>Firstly, this is the code I have created to make the call and then
>extract a few bits of information:
>>
>'Create the web request
>>
>Dim request As HttpWebRequest =
>WebRequest .Create(https://api.games.betfair.com/rest/v...sername=******)
>request.Me thod = "GET"
>request.Ti meout = 5000
>>
>'Add headers to the web request
>request.He aders.Add("game xAPIAgent",
>********@h otmail.co.uk.my Games.4.0)
>request.He aders.Add("game xAPIAgentInstan ce",
>"0d69ee829 0ee2f9b336c1f06 0e3497a5")
>request.He aders.Add("game xAPIPassword", "*******")
>>
>'Get response
>Dim response As HttpWebResponse = request.GetResp onse()
>>
>Dim reader As StreamReader = New
>StreamRead er(response.Get ResponseStream)
>Dim objDoc As XmlReader = XmlReader.Creat e(reader)
>objDoc.Mov eToContent()
>objDoc.Rea dToFollowing("s tatus")
>Me.StatusT extBox.Text = objDoc.ReadElem entContentAsStr ing
>objDoc.Rea dToFollowing("g ame")
>Me.GameIDT extBox.Text = objDoc.GetAttri bute("id").ToSt ring
>objDoc.Rea dToFollowing("r ound")
>Me.RoundNu mberTextBox.Tex t = objDoc.ReadElem entContentAsStr ing
>objDoc.Rea dToFollowing("b ettingWindowPer centageComplete ")
>Me.Percent ageTimeTextBox. Text = objDoc.ReadElem entContentAsStr ing
>CallLabel. Text = "captured"
>Catch ex As Exception
>CallLabel. Text = "not captured"
>End Try
>>
>For the most part this works fine but what I would rather do, is
>point directly to the nodes listed in the code directly, now I have
>some tell me "//channelSnaphot/channel/status" is the way to go
>through a XMLSelectSingle Node, but I have tried and failed using that
>method.
>>
>Is there anyone out the who can improve on my code so I can make 20
>or 30 direct calls to the nodes in the Stream Response I receive
>below? I am pleased to say the layout of the response will never
>change so thats not an issue i need to address.
>>
>Regards
>>
>API Call Returns the following:
><channelSn apshot>
> <channel gameType="POKER " id="1444074" name="Exchange Poker
>Texas
>Hold'em" >
> <status>RUNNING </status>
> <game id="1817283">
> <round>3</round>
> <bettingWindowT ime>45</bettingWindowTi me>
>>
><bettingWi ndowPercentageC omplete>24</bettingWindowPe rcentageComplet e>
> <gameData>
> <object name="Hand 1">
> <description>On e Pair, Fours, Ace
>High,
>with Q, 8 Kickers</description>
> <status>IN_PLAY </status>
> <property name="Card 1" value="20"/>
> <property name="Card 2" value="29"/>
> </object>
> <object name="Hand 2">
> <description>On e Pair, Sixes, Ace
>High</description>
> <status>IN_PLAY </status>
> <property name="Card 1" value="5"/>
> <property name="Card 2" value="44"/>
> </object>
> <object name="Hand 3">
> <description>On e Pair, Fours, Ace
>High,
>with Q, 6 Kickers</description>
> <status>IN_PLAY </status>
> <property name="Card 1" value="31"/>
> <property name="Card 2" value="42"/>
> </object>
> <object name="Hand 4">
> <description>Ac e High</description>
> <status>IN_PLAY </status>
> <property name="Card 1" value="49"/>
> <property name="Card 2" value="45"/>
> </object>
> <object name="Community Cards">
> <description/>
> <status>N/A</status>
> <property name="Card 1" value="3"/>
> <property name="Card 2" value="13"/>
> <property name="Card 3" value="11"/>
> <property name="Card 4" value="NOT
>AVAILABL E"/>
> <property name="Card 5" value="NOT
>AVAILABL E"/>
> </object>
> </gameData>
> <markets currency="GBP">
> <market id="5615051">
> <status>ACTIV E</status>
> <commissionRate >2.5</commissionRate>
> <marketType>WIN _ONLY</marketType>
> <selections type="MainBets" >
> <selection id="658439">
> <name>Hand 1</name>
> <resource
>href="http s://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8439"
>responseTy pe="selectionTr adeActivity" title="Trade Activity"/>
> <status>IN_PLAY </status>
>>
><amountMat ched>22.74</amountMatched>
>>
><bestAvail ableToBackPrice s>
> <price
>amountUnma tched="204.42"> 6.6</price>
> <price
>amountUnma tched="381.64"> 6.55</price>
> <price
>amountUnma tched="576.92"> 6.5</price>
>>
></bestAvailableTo BackPrices>
>>
><bestAvail ableToLayPrices >
> <price
>amountUnma tched="74.6">6. 7</price>
> <price
>amountUnma tched="504.74"> 6.75</price>
> <price
>amountUnma tched="551.44"> 6.8</price>
>>
></bestAvailableTo LayPrices>
> </selection>
> <selection id="658440">
> <name>Hand 2</name>
> <resource
>href="http s://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8440"
>responseTy pe="selectionTr adeActivity" title="Trade Activity"/>
> <status>IN_PLAY </status>
>>
><amountMat ched>88.68</amountMatched>
>>
><bestAvail ableToBackPrice s>
> <price
>amountUnma tched="306.66"> 1.72</price>
> <price
>amountUnma tched="4127.36" >1.71</price>
> <price
>amountUnma tched="59.63">1 .7</price>
>>
></bestAvailableTo BackPrices>
>>
><bestAvail ableToLayPrices >
> <price
>amountUnma tched="99.98">1 .73</price>
> <price
>amountUnma tched="2188.96" >1.74</price>
> <price
>amountUnma tched="2200.77" >1.75</price>
>>
></bestAvailableTo LayPrices>
> </selection>
> <selection id="658441">
> <name>Hand 3</name>
> <resource
>href="http s://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8441"
>responseTy pe="selectionTr adeActivity" title="Trade Activity"/>
> <status>IN_PLAY </status>
>>
><amountMat ched>102.9</amountMatched>
>>
><bestAvail ableToBackPrice s>
> <price
>amountUnma tched="17.99">4 5.0</price>
> <price
>amountUnma tched="140.4">4 4.5</price>
> <price
>amountUnma tched="2.19">44 .0</price>
>>
></bestAvailableTo BackPrices>
>>
><bestAvail ableToLayPrices >
> <price
>amountUnma tched="33.52">4 6.0</price>
> <price
>amountUnma tched="53.76">4 6.5</price>
> <price
>amountUnma tched="79.76">4 7.0</price>
>>
></bestAvailableTo LayPrices>
> </selection>
> <selection id="658442">
> <name>Hand 4</name>
> <resource
>href="http s://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8442"
>responseTy pe="selectionTr adeActivity" title="Trade Activity"/>
> <status>IN_PLAY </status>
>>
><amountMat ched>1020.0</amountMatched>
>>
><bestAvail ableToBackPrice s>
> <price
>amountUnma tched="158.07"> 4.0</price>
> <price
>amountUnma tched="198.19"> 3.98</price>
> <price
>amountUnma tched="631.28"> 3.96</price>
>>
></bestAvailableTo BackPrices>
>>
><bestAvail ableToLayPrices >
> <price
>amountUnma tched="103.84"> 4.06</price>
> <price
>amountUnma tched="612.72"> 4.08</price>
> <price
>amountUnma tched="914.6">4 .1</price>
>>
></bestAvailableTo LayPrices>
> </selection>
> </selections>
> </market>
> </markets>
> </game>
> </channel>
> </channelSnapshot >
>>
>>
>


Feb 22 '07 #7
The full exception information please.

And at what statement does the exception occur?
"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
The err.description says Object reference not set to an instance of an
object.

"Stephany Young" <noone@localhos twrote in message
news:Os******** ******@TK2MSFTN GP04.phx.gbl...
>OK ...

What results do you get as you interrogate each node?

If you get exceptions then please post the full exception information.

"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
news:Oq******* *******@TK2MSFT NGP02.phx.gbl.. .
>>>I get the following, sorry no formatting, when i put your code into my
program it still does not work so what am i missing?

<?xml version="1.0" encoding="UTF-8" standalone="yes "?>
<?xml-stylesheet type="text/xsl" href="/rest/apiStylesheet.x sl" ?>
<channelSnaps hot xmlns="urn:betf air:games:api:v 1">
<channel gameType="POKER " id="1444074" name="Exchange Poker Texas
Hold'em">
<status>RUNNING </status>
<game id="1823743">
<round>2</round>
<bettingWindowT ime>60</bettingWindowTi me>
<bettingWindowP ercentageComple te>25</bettingWindowPe rcentageComplet e>
<gameData>
<object name="Hand 1">
<description /><status>IN_PLA Y</status><propert y name="Card
1" value="26" /><property name="Card 2" value="1" /></object><object
name="Hand 2"><descript ion /><status>IN_PLA Y</status><propert y
name="Card 1" value="22" /><property name="Card 2" value="34"
/></object><object name="Hand 3"><descript ion
/><status>IN_PLA Y</status><propert y name="Card 1" value="7" /><property
name="Card 2" value="47" /></object><object name="Hand 4"><descript ion
/><status>IN_PLA Y</status><propert y name="Card 1" value="39" /><property
name="Card 2" value="33" /></object><object name="Community
Cards"><descr iption /><status>N/A</status><propert y name="Card 1"
value="NOT AVAILABLE" /><property name="Card 2" value="NOT AVAILABLE"
/><property name="Card 3" value="NOT AVAILABLE" /><property name="Card
4" value="NOT AVAILABLE" /><property name="Card 5" value="NOT AVAILABLE"
/></object></gameData><marke ts currency="GBP"> <market
id="5627743"> <status>ACTIV E</status><commiss ionRate>2.5</commissionRate> <marketType>WIN _ONLY</marketType><sel ections
type="MainBet s"><selectio n id="658439"><na me>Hand 1</name><resource
href="https ://api.games.betfa ir.com/rest/v1/selection/tradeActivity?u sername=kingten clubs&amp;marke tId=5627743&amp ;selectionId=65 8439"
responseType= "selectionTrade Activity" title="Trade Activity"
/><status>IN_PLA Y</status><amountM atched>148.76</amountMatched>< bestAvailableTo BackPrices><pri ce
amountUnmatch ed="146.29">4.3 </price><price
amountUnmatch ed="785.42">4.2 8</price><price
amountUnmatch ed="880.28">4.2 6</price></bestAvailableTo BackPrices><bes tAvailableToLay Prices><price
amountUnmatch ed="62.16">4.34 </price><price
amountUnmatch ed="228.21">4.3 6</price><price
amountUnmatch ed="570.76">4.3 8</price></bestAvailableTo LayPrices></selection><sele ction
id="658440">< name>Hand 2</name><resource
href="https ://api.games.betfa ir.com/rest/v1/selection/tradeActivity?u sername=kingten clubs&amp;marke tId=5627743&amp ;selectionId=65 8440"
responseType= "selectionTrade Activity" title="Trade Activity"
/><status>IN_PLA Y</status><amountM atched>79.38</amountMatched>< bestAvailableTo BackPrices><pri ce
amountUnmatch ed="263.15">2.9 4</price><price
amountUnmatch ed="1109.2">2.9 3</price><price
amountUnmatch ed="1288.64">2. 91</price></bestAvailableTo BackPrices><bes tAvailableToLay Prices><price
amountUnmatch ed="183.92">2.9 7</price><price
amountUnmatch ed="294.17">2.9 8</price><price
amountUnmatch ed="836.12">2.9 9</price></bestAvailableTo LayPrices></selection><sele ction
id="658441">< name>Hand 3</name><resource
href="https ://api.games.betfa ir.com/rest/v1/selection/tradeActivity?u sername=kingten clubs&amp;marke tId=5627743&amp ;selectionId=65 8441"
responseType= "selectionTrade Activity" title="Trade Activity"
/><status>IN_PLA Y</status><amountM atched>173.92</amountMatched>< bestAvailableTo BackPrices><pri ce
amountUnmatch ed="50.6">7.8</price><price
amountUnmatch ed="447.26">7.7 5</price><price
amountUnmatch ed="487.0">7.7 </price></bestAvailableTo BackPrices><bes tAvailableToLay Prices><price
amountUnmatch ed="169.6">7.9 </price><price
amountUnmatch ed="314.44">7.9 5</price><price
amountUnmatch ed="468.72">8.0 </price></bestAvailableTo LayPrices></selection><sele ction
id="658442">< name>Hand 4</name><resource
href="https ://api.games.betfa ir.com/rest/v1/selection/tradeActivity?u sername=kingten clubs&amp;marke tId=5627743&amp ;selectionId=65 8442"
responseType= "selectionTrade Activity" title="Trade Activity"
/><status>IN_PLA Y</status><amountM atched>131.4</amountMatched>< bestAvailableTo BackPrices><pri ce
amountUnmatch ed="381.11">3.2 8</price><price
amountUnmatch ed="766.84">3.2 6</price><price
amountUnmatch ed="1157.4">3.2 4</price></bestAvailableTo BackPrices><bes tAvailableToLay Prices><price
amountUnmatch ed="230.47">3.3 2</price><price
amountUnmatch ed="973.0">3.34 </price><price
amountUnmatch ed="1116.04">3. 36</price></bestAvailableTo LayPrices></selection></selections></market></markets></game></channel></channelSnapshot >

"Stephany Young" <noone@localhos twrote in message
news:e%****** **********@TK2M SFTNGP04.phx.gb l...
Given the XML that you have provided, the following produces the
results as shown (I saved the XML to a file for the purpose of the
exercise):

Dim _doc As New XmlDocument
_doc.Load("chan nelSnapshot.xml ")
Dim _node As XmlNode = _doc.SelectSing leNode("//channel/status")
Console.WriteLi ne(_node.InnerT ext)
_node = _doc.SelectSing leNode("//channel/game")
Console.WriteLi ne(_node.Attrib utes("id").Valu e)
_node = _doc.SelectSing leNode("//channel/game/round")
Console.WriteLi ne(_node.InnerT ext)
_node =
_doc.SelectS ingleNode("//channel/game/bettingWindowPe rcentageComplet e")
Console.WriteLi ne(_node.InnerT ext)

Results
-------
RUNNING
1817283
3
24

If you change the XPath expressions or change the scope of the
SelectSingle Node method, then it will not work.

Out of interest, what do you get if you execute the equivalent of:

Console.WriteLi ne(_doc.OuterXm l)

immediatel y after 'loading' the XmlDocument object from the
StreamRead er object?
"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
news:%2***** ***********@TK2 MSFTNGP04.phx.g bl...
And I did say, i have tried many variatons including yours but it did
not work
>
"Stephany Young" <noone@localhos twrote in message
news:Oq**** **********@TK2M SFTNGP02.phx.gb l...
>Again with the changing of it!!!!!!!
>>
>I DID NOT say:
>>
> objDoc.SelectSi ngleNode("//channelSnaphot/channel/status")
>>
>I DID say:
>>
> objDoc.SelectSi ngleNode("//channel/status")
>>
>I don't know why you persist in inserting channelSnaphot/ into the
>query!
>>
>//channel/status means find me the first element called status that
>is a descendant of an element called channel that occurs anywhere in
>the document.
>>
>>
>>
>"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
>news:u%*** *************@T K2MSFTNGP06.phx .gbl...
>>Good afternoon, yes i am a newby so pls keep it simple.
>>>
>>Yesterd ay I started a small project where I have to make an API call
>>and receive back from that the long xml transcript down below.
>>>
>>Now, not knowing about XML I have experienced one or 2 issues.
>>>
>>Firstly , this is the code I have created to make the call and then
>>extract a few bits of information:
>>>
>>'Create the web request
>>>
>>Dim request As HttpWebRequest =
>>WebReques t.Create(https://api.games.betfair.com/rest/v...sername=******)
>>request.M ethod = "GET"
>>request.T imeout = 5000
>>>
>>'Add headers to the web request
>>request.H eaders.Add("gam exAPIAgent",
>>********@ hotmail.co.uk.m yGames.4.0)
>>request.H eaders.Add("gam exAPIAgentInsta nce",
>>"0d69ee82 90ee2f9b336c1f0 60e3497a5")
>>request.H eaders.Add("gam exAPIPassword", "*******")
>>>
>>'Get response
>>Dim response As HttpWebResponse = request.GetResp onse()
>>>
>>Dim reader As StreamReader = New
>>StreamRea der(response.Ge tResponseStream )
>>Dim objDoc As XmlReader = XmlReader.Creat e(reader)
>>objDoc.Mo veToContent()
>>objDoc.Re adToFollowing(" status")
>>Me.Status TextBox.Text = objDoc.ReadElem entContentAsStr ing
>>objDoc.Re adToFollowing(" game")
>>Me.GameID TextBox.Text = objDoc.GetAttri bute("id").ToSt ring
>>objDoc.Re adToFollowing(" round")
>>Me.RoundN umberTextBox.Te xt = objDoc.ReadElem entContentAsStr ing
>>objDoc.Re adToFollowing(" bettingWindowPe rcentageComplet e")
>>Me.Percen tageTimeTextBox .Text = objDoc.ReadElem entContentAsStr ing
>>CallLabel .Text = "captured"
>>Catch ex As Exception
>>CallLabel .Text = "not captured"
>>End Try
>>>
>>For the most part this works fine but what I would rather do, is
>>point directly to the nodes listed in the code directly, now I have
>>some tell me "//channelSnaphot/channel/status" is the way to go
>>through a XMLSelectSingle Node, but I have tried and failed using
>>that method.
>>>
>>Is there anyone out the who can improve on my code so I can make 20
>>or 30 direct calls to the nodes in the Stream Response I receive
>>below? I am pleased to say the layout of the response will never
>>change so thats not an issue i need to address.
>>>
>>Regards
>>>
>>API Call Returns the following:
>><channelS napshot>
>> <channel gameType="POKER " id="1444074" name="Exchange Poker
>>Texas
>>Hold'em ">
>> <status>RUNNING </status>
>> <game id="1817283">
>> <round>3</round>
>> <bettingWindowT ime>45</bettingWindowTi me>
>>>
>><bettingW indowPercentage Complete>24</bettingWindowPe rcentageComplet e>
>> <gameData>
>> <object name="Hand 1">
>> <description>On e Pair, Fours, Ace
>>High,
>>with Q, 8 Kickers</description>
>> <status>IN_PLAY </status>
>> <property name="Card 1" value="20"/>
>> <property name="Card 2" value="29"/>
>> </object>
>> <object name="Hand 2">
>> <description>On e Pair, Sixes, Ace
>>High</description>
>> <status>IN_PLAY </status>
>> <property name="Card 1" value="5"/>
>> <property name="Card 2" value="44"/>
>> </object>
>> <object name="Hand 3">
>> <description>On e Pair, Fours, Ace
>>High,
>>with Q, 6 Kickers</description>
>> <status>IN_PLAY </status>
>> <property name="Card 1" value="31"/>
>> <property name="Card 2" value="42"/>
>> </object>
>> <object name="Hand 4">
>> <description>Ac e High</description>
>> <status>IN_PLAY </status>
>> <property name="Card 1" value="49"/>
>> <property name="Card 2" value="45"/>
>> </object>
>> <object name="Community Cards">
>> <description/>
>> <status>N/A</status>
>> <property name="Card 1" value="3"/>
>> <property name="Card 2" value="13"/>
>> <property name="Card 3" value="11"/>
>> <property name="Card 4" value="NOT
>>AVAILABLE "/>
>> <property name="Card 5" value="NOT
>>AVAILABLE "/>
>> </object>
>> </gameData>
>> <markets currency="GBP">
>> <market id="5615051">
>> <status>ACTIV E</status>
>> <commissionRate >2.5</commissionRate>
>> <marketType>WIN _ONLY</marketType>
>> <selections type="MainBets" >
>> <selection id="658439">
>> <name>Hand 1</name>
>> <resource
>>href="htt ps://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8439"
>>responseT ype="selectionT radeActivity" title="Trade Activity"/>
>> <status>IN_PLAY </status>
>>>
>><amountMa tched>22.74</amountMatched>
>>>
>><bestAvai lableToBackPric es>
>> <price
>>amountUnm atched="204.42" >6.6</price>
>> <price
>>amountUnm atched="381.64" >6.55</price>
>> <price
>>amountUnm atched="576.92" >6.5</price>
>>>
>></bestAvailableTo BackPrices>
>>>
>><bestAvai lableToLayPrice s>
>> <price
>>amountUnm atched="74.6">6 .7</price>
>> <price
>>amountUnm atched="504.74" >6.75</price>
>> <price
>>amountUnm atched="551.44" >6.8</price>
>>>
>></bestAvailableTo LayPrices>
>> </selection>
>> <selection id="658440">
>> <name>Hand 2</name>
>> <resource
>>href="htt ps://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8440"
>>responseT ype="selectionT radeActivity" title="Trade Activity"/>
>> <status>IN_PLAY </status>
>>>
>><amountMa tched>88.68</amountMatched>
>>>
>><bestAvai lableToBackPric es>
>> <price
>>amountUnm atched="306.66" >1.72</price>
>> <price
>>amountUnm atched="4127.36 ">1.71</price>
>> <price
>>amountUnm atched="59.63"> 1.7</price>
>>>
>></bestAvailableTo BackPrices>
>>>
>><bestAvai lableToLayPrice s>
>> <price
>>amountUnm atched="99.98"> 1.73</price>
>> <price
>>amountUnm atched="2188.96 ">1.74</price>
>> <price
>>amountUnm atched="2200.77 ">1.75</price>
>>>
>></bestAvailableTo LayPrices>
>> </selection>
>> <selection id="658441">
>> <name>Hand 3</name>
>> <resource
>>href="htt ps://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8441"
>>responseT ype="selectionT radeActivity" title="Trade Activity"/>
>> <status>IN_PLAY </status>
>>>
>><amountMa tched>102.9</amountMatched>
>>>
>><bestAvai lableToBackPric es>
>> <price
>>amountUnm atched="17.99"> 45.0</price>
>> <price
>>amountUnm atched="140.4"> 44.5</price>
>> <price
>>amountUnm atched="2.19">4 4.0</price>
>>>
>></bestAvailableTo BackPrices>
>>>
>><bestAvai lableToLayPrice s>
>> <price
>>amountUnm atched="33.52"> 46.0</price>
>> <price
>>amountUnm atched="53.76"> 46.5</price>
>> <price
>>amountUnm atched="79.76"> 47.0</price>
>>>
>></bestAvailableTo LayPrices>
>> </selection>
>> <selection id="658442">
>> <name>Hand 4</name>
>> <resource
>>href="htt ps://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8442"
>>responseT ype="selectionT radeActivity" title="Trade Activity"/>
>> <status>IN_PLAY </status>
>>>
>><amountMa tched>1020.0</amountMatched>
>>>
>><bestAvai lableToBackPric es>
>> <price
>>amountUnm atched="158.07" >4.0</price>
>> <price
>>amountUnm atched="198.19" >3.98</price>
>> <price
>>amountUnm atched="631.28" >3.96</price>
>>>
>></bestAvailableTo BackPrices>
>>>
>><bestAvai lableToLayPrice s>
>> <price
>>amountUnm atched="103.84" >4.06</price>
>> <price
>>amountUnm atched="612.72" >4.08</price>
>> <price
>>amountUnm atched="914.6"> 4.1</price>
>>>
>></bestAvailableTo LayPrices>
>> </selection>
>> </selections>
>> </market>
>> </markets>
>> </game>
>> </channel>
>> </channelSnapshot >
>>>
>>>
>>
>
>

Feb 22 '07 #8
Dim _doc As New XmlDocument

_doc.Load(reade r)

TextBox1.Text = (_doc.OuterXml)

Dim _node As XmlNode = _doc.SelectSing leNode("//channel/status")

StatusTextBox.T ext = _node.InnerText 'This is where it breaks and it says

NullReferenceEx ception was unhandled
Object reference not set to an instance of an object

"Stephany Young" <noone@localhos twrote in message
news:ui******** ******@TK2MSFTN GP03.phx.gbl...
The full exception information please.

And at what statement does the exception occur?
"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
>The err.description says Object reference not set to an instance of an
object.

"Stephany Young" <noone@localhos twrote in message
news:Os******* *******@TK2MSFT NGP04.phx.gbl.. .
>>OK ...

What results do you get as you interrogate each node?

If you get exceptions then please post the full exception information.

"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
news:Oq****** ********@TK2MSF TNGP02.phx.gbl. ..
I get the following, sorry no formatting, when i put your code into my
program it still does not work so what am i missing?

<?xml version="1.0" encoding="UTF-8" standalone="yes "?>
<?xml-stylesheet type="text/xsl" href="/rest/apiStylesheet.x sl" ?>
<channelSnap shot xmlns="urn:betf air:games:api:v 1">
<channel gameType="POKER " id="1444074" name="Exchange Poker Texas
Hold'em">
<status>RUNNING </status>
<game id="1823743">
<round>2</round>
<bettingWindowT ime>60</bettingWindowTi me>

<bettingWind owPercentageCom plete>25</bettingWindowPe rcentageComplet e>
<gameData>
<object name="Hand 1">
<description /><status>IN_PLA Y</status><propert y name="Card
1" value="26" /><property name="Card 2" value="1" /></object><object
name="Hand 2"><descript ion /><status>IN_PLA Y</status><propert y
name="Card 1" value="22" /><property name="Card 2" value="34"
/></object><object name="Hand 3"><descript ion
/><status>IN_PLA Y</status><propert y name="Card 1" value="7" /><property
name="Card 2" value="47" /></object><object name="Hand 4"><descript ion
/><status>IN_PLA Y</status><propert y name="Card 1" value="39"
/><property name="Card 2" value="33" /></object><object name="Community
Cards"><desc ription /><status>N/A</status><propert y name="Card 1"
value="NOT AVAILABLE" /><property name="Card 2" value="NOT AVAILABLE"
/><property name="Card 3" value="NOT AVAILABLE" /><property name="Card
4" value="NOT AVAILABLE" /><property name="Card 5" value="NOT
AVAILABLE" /></object></gameData><marke ts currency="GBP"> <market
id="5627743" ><status>ACTIVE </status><commiss ionRate>2.5</commissionRate> <marketType>WIN _ONLY</marketType><sel ections
type="MainBe ts"><selectio n id="658439"><na me>Hand 1</name><resource
href="http s://api.games.betfa ir.com/rest/v1/selection/tradeActivity?u sername=kingten clubs&amp;marke tId=5627743&amp ;selectionId=65 8439"
responseType ="selectionTrad eActivity" title="Trade Activity"
/><status>IN_PLA Y</status><amountM atched>148.76</amountMatched>< bestAvailableTo BackPrices><pri ce
amountUnmatc hed="146.29">4. 3</price><price
amountUnmatc hed="785.42">4. 28</price><price
amountUnmatc hed="880.28">4. 26</price></bestAvailableTo BackPrices><bes tAvailableToLay Prices><price
amountUnmatc hed="62.16">4.3 4</price><price
amountUnmatc hed="228.21">4. 36</price><price
amountUnmatc hed="570.76">4. 38</price></bestAvailableTo LayPrices></selection><sele ction
id="658440"> <name>Hand 2</name><resource
href="http s://api.games.betfa ir.com/rest/v1/selection/tradeActivity?u sername=kingten clubs&amp;marke tId=5627743&amp ;selectionId=65 8440"
responseType ="selectionTrad eActivity" title="Trade Activity"
/><status>IN_PLA Y</status><amountM atched>79.38</amountMatched>< bestAvailableTo BackPrices><pri ce
amountUnmatc hed="263.15">2. 94</price><price
amountUnmatc hed="1109.2">2. 93</price><price
amountUnmatc hed="1288.64">2 .91</price></bestAvailableTo BackPrices><bes tAvailableToLay Prices><price
amountUnmatc hed="183.92">2. 97</price><price
amountUnmatc hed="294.17">2. 98</price><price
amountUnmatc hed="836.12">2. 99</price></bestAvailableTo LayPrices></selection><sele ction
id="658441"> <name>Hand 3</name><resource
href="http s://api.games.betfa ir.com/rest/v1/selection/tradeActivity?u sername=kingten clubs&amp;marke tId=5627743&amp ;selectionId=65 8441"
responseType ="selectionTrad eActivity" title="Trade Activity"
/><status>IN_PLA Y</status><amountM atched>173.92</amountMatched>< bestAvailableTo BackPrices><pri ce
amountUnmatc hed="50.6">7.8</price><price
amountUnmatc hed="447.26">7. 75</price><price
amountUnmatc hed="487.0">7.7 </price></bestAvailableTo BackPrices><bes tAvailableToLay Prices><price
amountUnmatc hed="169.6">7.9 </price><price
amountUnmatc hed="314.44">7. 95</price><price
amountUnmatc hed="468.72">8. 0</price></bestAvailableTo LayPrices></selection><sele ction
id="658442"> <name>Hand 4</name><resource
href="http s://api.games.betfa ir.com/rest/v1/selection/tradeActivity?u sername=kingten clubs&amp;marke tId=5627743&amp ;selectionId=65 8442"
responseType ="selectionTrad eActivity" title="Trade Activity"
/><status>IN_PLA Y</status><amountM atched>131.4</amountMatched>< bestAvailableTo BackPrices><pri ce
amountUnmatc hed="381.11">3. 28</price><price
amountUnmatc hed="766.84">3. 26</price><price
amountUnmatc hed="1157.4">3. 24</price></bestAvailableTo BackPrices><bes tAvailableToLay Prices><price
amountUnmatc hed="230.47">3. 32</price><price
amountUnmatc hed="973.0">3.3 4</price><price
amountUnmatc hed="1116.04">3 .36</price></bestAvailableTo LayPrices></selection></selections></market></markets></game></channel></channelSnapshot >

"Stephany Young" <noone@localhos twrote in message
news:e%***** ***********@TK2 MSFTNGP04.phx.g bl...
Given the XML that you have provided, the following produces the
results as shown (I saved the XML to a file for the purpose of the
exercise) :
>
Dim _doc As New XmlDocument
_doc.Load("chan nelSnapshot.xml ")
Dim _node As XmlNode = _doc.SelectSing leNode("//channel/status")
Console.WriteLi ne(_node.InnerT ext)
_node = _doc.SelectSing leNode("//channel/game")
Console.WriteLi ne(_node.Attrib utes("id").Valu e)
_node = _doc.SelectSing leNode("//channel/game/round")
Console.WriteLi ne(_node.InnerT ext)
_node =
_doc.Select SingleNode("//channel/game/bettingWindowPe rcentageComplet e")
Console.WriteLi ne(_node.InnerT ext)
>
Results
-------
RUNNING
1817283
3
24
>
If you change the XPath expressions or change the scope of the
SelectSingl eNode method, then it will not work.
>
Out of interest, what do you get if you execute the equivalent of:
>
Console.WriteLi ne(_doc.OuterXm l)
>
immediate ly after 'loading' the XmlDocument object from the
StreamReade r object?
>
>
"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
news:%2**** ************@TK 2MSFTNGP04.phx. gbl...
>And I did say, i have tried many variatons including yours but it did
>not work
>>
>"Stephan y Young" <noone@localhos twrote in message
>news:Oq*** ***********@TK2 MSFTNGP02.phx.g bl...
>>Again with the changing of it!!!!!!!
>>>
>>I DID NOT say:
>>>
>> objDoc.SelectSi ngleNode("//channelSnaphot/channel/status")
>>>
>>I DID say:
>>>
>> objDoc.SelectSi ngleNode("//channel/status")
>>>
>>I don't know why you persist in inserting channelSnaphot/ into the
>>query!
>>>
>>//channel/status means find me the first element called status that
>>is a descendant of an element called channel that occurs anywhere in
>>the document.
>>>
>>>
>>>
>>"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
>>news:u%** **************@ TK2MSFTNGP06.ph x.gbl...
>>>Good afternoon, yes i am a newby so pls keep it simple.
>>>>
>>>Yesterda y I started a small project where I have to make an API
>>>call and receive back from that the long xml transcript down below.
>>>>
>>>Now, not knowing about XML I have experienced one or 2 issues.
>>>>
>>>Firstl y, this is the code I have created to make the call and then
>>>extrac t a few bits of information:
>>>>
>>>'Creat e the web request
>>>>
>>>Dim request As HttpWebRequest =
>>>WebReque st.Create(https://api.games.betfair.com/rest/v...sername=******)
>>>request. Method = "GET"
>>>request. Timeout = 5000
>>>>
>>>'Add headers to the web request
>>>request. Headers.Add("ga mexAPIAgent",
>>>******** @hotmail.co.uk. myGames.4.0)
>>>request. Headers.Add("ga mexAPIAgentInst ance",
>>>"0d69ee8 290ee2f9b336c1f 060e3497a5")
>>>request. Headers.Add("ga mexAPIPassword" , "*******")
>>>>
>>>'Get response
>>>Dim response As HttpWebResponse = request.GetResp onse()
>>>>
>>>Dim reader As StreamReader = New
>>>StreamRe ader(response.G etResponseStrea m)
>>>Dim objDoc As XmlReader = XmlReader.Creat e(reader)
>>>objDoc.M oveToContent()
>>>objDoc.R eadToFollowing( "status")
>>>Me.Statu sTextBox.Text = objDoc.ReadElem entContentAsStr ing
>>>objDoc.R eadToFollowing( "game")
>>>Me.GameI DTextBox.Text = objDoc.GetAttri bute("id").ToSt ring
>>>objDoc.R eadToFollowing( "round")
>>>Me.Round NumberTextBox.T ext = objDoc.ReadElem entContentAsStr ing
>>>objDoc.R eadToFollowing( "bettingWindowP ercentageComple te")
>>>Me.Perce ntageTimeTextBo x.Text = objDoc.ReadElem entContentAsStr ing
>>>CallLabe l.Text = "captured"
>>>Catch ex As Exception
>>>CallLabe l.Text = "not captured"
>>>End Try
>>>>
>>>For the most part this works fine but what I would rather do, is
>>>point directly to the nodes listed in the code directly, now I have
>>>some tell me "//channelSnaphot/channel/status" is the way to go
>>>throug h a XMLSelectSingle Node, but I have tried and failed using
>>>that method.
>>>>
>>>Is there anyone out the who can improve on my code so I can make 20
>>>or 30 direct calls to the nodes in the Stream Response I receive
>>>below? I am pleased to say the layout of the response will never
>>>change so thats not an issue i need to address.
>>>>
>>>Regard s
>>>>
>>>API Call Returns the following:
>>><channel Snapshot>
>>> <channel gameType="POKER " id="1444074" name="Exchange Poker
>>>Texas
>>>Hold'em" >
>>> <status>RUNNING </status>
>>> <game id="1817283">
>>> <round>3</round>
>>> <bettingWindowT ime>45</bettingWindowTi me>
>>>>
>>><betting WindowPercentag eComplete>24</bettingWindowPe rcentageComplet e>
>>> <gameData>
>>> <object name="Hand 1">
>>> <description>On e Pair, Fours, Ace
>>>High,
>>>with Q, 8 Kickers</description>
>>> <status>IN_PLAY </status>
>>> <property name="Card 1"
>>>value="2 0"/>
>>> <property name="Card 2"
>>>value="2 9"/>
>>> </object>
>>> <object name="Hand 2">
>>> <description>On e Pair, Sixes, Ace
>>>High</description>
>>> <status>IN_PLAY </status>
>>> <property name="Card 1" value="5"/>
>>> <property name="Card 2"
>>>value="4 4"/>
>>> </object>
>>> <object name="Hand 3">
>>> <description>On e Pair, Fours, Ace
>>>High,
>>>with Q, 6 Kickers</description>
>>> <status>IN_PLAY </status>
>>> <property name="Card 1"
>>>value="3 1"/>
>>> <property name="Card 2"
>>>value="4 2"/>
>>> </object>
>>> <object name="Hand 4">
>>> <description>Ac e High</description>
>>> <status>IN_PLAY </status>
>>> <property name="Card 1"
>>>value="4 9"/>
>>> <property name="Card 2"
>>>value="4 5"/>
>>> </object>
>>> <object name="Community Cards">
>>> <description/>
>>> <status>N/A</status>
>>> <property name="Card 1" value="3"/>
>>> <property name="Card 2"
>>>value="1 3"/>
>>> <property name="Card 3"
>>>value="1 1"/>
>>> <property name="Card 4" value="NOT
>>>AVAILABL E"/>
>>> <property name="Card 5" value="NOT
>>>AVAILABL E"/>
>>> </object>
>>> </gameData>
>>> <markets currency="GBP">
>>> <market id="5615051">
>>> <status>ACTIV E</status>
>>>>
>>><commiss ionRate>2.5</commissionRate>
>>> <marketType>WIN _ONLY</marketType>
>>> <selections type="MainBets" >
>>> <selection id="658439">
>>> <name>Hand 1</name>
>>> <resource
>>>href="ht tps://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8439"
>>>response Type="selection TradeActivity" title="Trade Activity"/>
>>>>
>>><status> IN_PLAY</status>
>>>>
>>><amountM atched>22.74</amountMatched>
>>>>
>>><bestAva ilableToBackPri ces>
>>> <price
>>>amountUn matched="204.42 ">6.6</price>
>>> <price
>>>amountUn matched="381.64 ">6.55</price>
>>> <price
>>>amountUn matched="576.92 ">6.5</price>
>>>>
>>></bestAvailableTo BackPrices>
>>>>
>>><bestAva ilableToLayPric es>
>>> <price
>>>amountUn matched="74.6"> 6.7</price>
>>> <price
>>>amountUn matched="504.74 ">6.75</price>
>>> <price
>>>amountUn matched="551.44 ">6.8</price>
>>>>
>>></bestAvailableTo LayPrices>
>>> </selection>
>>> <selection id="658440">
>>> <name>Hand 2</name>
>>> <resource
>>>href="ht tps://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8440"
>>>response Type="selection TradeActivity" title="Trade Activity"/>
>>>>
>>><status> IN_PLAY</status>
>>>>
>>><amountM atched>88.68</amountMatched>
>>>>
>>><bestAva ilableToBackPri ces>
>>> <price
>>>amountUn matched="306.66 ">1.72</price>
>>> <price
>>>amountUn matched="4127.3 6">1.71</price>
>>> <price
>>>amountUn matched="59.63" >1.7</price>
>>>>
>>></bestAvailableTo BackPrices>
>>>>
>>><bestAva ilableToLayPric es>
>>> <price
>>>amountUn matched="99.98" >1.73</price>
>>> <price
>>>amountUn matched="2188.9 6">1.74</price>
>>> <price
>>>amountUn matched="2200.7 7">1.75</price>
>>>>
>>></bestAvailableTo LayPrices>
>>> </selection>
>>> <selection id="658441">
>>> <name>Hand 3</name>
>>> <resource
>>>href="ht tps://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8441"
>>>response Type="selection TradeActivity" title="Trade Activity"/>
>>>>
>>><status> IN_PLAY</status>
>>>>
>>><amountM atched>102.9</amountMatched>
>>>>
>>><bestAva ilableToBackPri ces>
>>> <price
>>>amountUn matched="17.99" >45.0</price>
>>> <price
>>>amountUn matched="140.4" >44.5</price>
>>> <price
>>>amountUn matched="2.19"> 44.0</price>
>>>>
>>></bestAvailableTo BackPrices>
>>>>
>>><bestAva ilableToLayPric es>
>>> <price
>>>amountUn matched="33.52" >46.0</price>
>>> <price
>>>amountUn matched="53.76" >46.5</price>
>>> <price
>>>amountUn matched="79.76" >47.0</price>
>>>>
>>></bestAvailableTo LayPrices>
>>> </selection>
>>> <selection id="658442">
>>> <name>Hand 4</name>
>>> <resource
>>>href="ht tps://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8442"
>>>response Type="selection TradeActivity" title="Trade Activity"/>
>>>>
>>><status> IN_PLAY</status>
>>>>
>>><amountM atched>1020.0</amountMatched>
>>>>
>>><bestAva ilableToBackPri ces>
>>> <price
>>>amountUn matched="158.07 ">4.0</price>
>>> <price
>>>amountUn matched="198.19 ">3.98</price>
>>> <price
>>>amountUn matched="631.28 ">3.96</price>
>>>>
>>></bestAvailableTo BackPrices>
>>>>
>>><bestAva ilableToLayPric es>
>>> <price
>>>amountUn matched="103.84 ">4.06</price>
>>> <price
>>>amountUn matched="612.72 ">4.08</price>
>>> <price
>>>amountUn matched="914.6" >4.1</price>
>>>>
>>></bestAvailableTo LayPrices>
>>> </selection>
>>> </selections>
>>> </market>
>>> </markets>
>>> </game>
>>> </channel>
>>> </channelSnapshot >
>>>>
>>>>
>>>
>>
>>
>


Feb 22 '07 #9
Humour me ...

What results do you get if you add the statement:

reader.Close()

directly after the statement:

_doc.Load(reade r)
"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
news:ON******** *****@TK2MSFTNG P06.phx.gbl...
Dim _doc As New XmlDocument

_doc.Load(reade r)

TextBox1.Text = (_doc.OuterXml)

Dim _node As XmlNode = _doc.SelectSing leNode("//channel/status")

StatusTextBox.T ext = _node.InnerText 'This is where it breaks and it says

NullReferenceEx ception was unhandled
Object reference not set to an instance of an object

"Stephany Young" <noone@localhos twrote in message
news:ui******** ******@TK2MSFTN GP03.phx.gbl...
>The full exception information please.

And at what statement does the exception occur?
"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
news:%2******* *********@TK2MS FTNGP05.phx.gbl ...
>>The err.description says Object reference not set to an instance of an
object.

"Stephany Young" <noone@localhos twrote in message
news:Os****** ********@TK2MSF TNGP04.phx.gbl. ..
OK ...

What results do you get as you interrogate each node?

If you get exceptions then please post the full exception information.

"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
news:Oq***** *********@TK2MS FTNGP02.phx.gbl ...
>I get the following, sorry no formatting, when i put your code into my
>program it still does not work so what am i missing?
>
<?xml version="1.0" encoding="UTF-8" standalone="yes "?>
<?xml-stylesheet type="text/xsl" href="/rest/apiStylesheet.x sl" ?>
<channelSna pshot xmlns="urn:betf air:games:api:v 1">
<channel gameType="POKER " id="1444074" name="Exchange Poker Texas
Hold'em">
<status>RUNNING </status>
<game id="1823743">
<round>2</round>
<bettingWindowT ime>60</bettingWindowTi me>
>
<bettingWin dowPercentageCo mplete>25</bettingWindowPe rcentageComplet e>
<gameData>
<object name="Hand 1">
<description /><status>IN_PLA Y</status><propert y name="Card
1" value="26" /><property name="Card 2" value="1" /></object><object
name="Han d 2"><descript ion /><status>IN_PLA Y</status><propert y
name="Car d 1" value="22" /><property name="Card 2" value="34"
/></object><object name="Hand 3"><descript ion
/><status>IN_PLA Y</status><propert y name="Card 1" value="7"
/><property name="Card 2" value="47" /></object><object name="Hand
4"><descrip tion /><status>IN_PLA Y</status><propert y name="Card 1"
value="39 " /><property name="Card 2" value="33" /></object><object
name="Commu nity Cards"><descrip tion /><status>N/A</status><propert y
name="Car d 1" value="NOT AVAILABLE" /><property name="Card 2"
value="NO T AVAILABLE" /><property name="Card 3" value="NOT AVAILABLE"
/><property name="Card 4" value="NOT AVAILABLE" /><property name="Card
5" value="NOT AVAILABLE" /></object></gameData><marke ts
currency="G BP"><market
id="5627743 "><status>ACTIV E</status><commiss ionRate>2.5</commissionRate> <marketType>WIN _ONLY</marketType><sel ections
type="MainB ets"><selectio n id="658439"><na me>Hand 1</name><resource
href="https ://api.games.betfa ir.com/rest/v1/selection/tradeActivity?u sername=kingten clubs&amp;marke tId=5627743&amp ;selectionId=65 8439"
responseTyp e="selectionTra deActivity" title="Trade Activity"
/><status>IN_PLA Y</status><amountM atched>148.76</amountMatched>< bestAvailableTo BackPrices><pri ce
amountUnmat ched="146.29">4 .3</price><price
amountUnmat ched="785.42">4 .28</price><price
amountUnmat ched="880.28">4 .26</price></bestAvailableTo BackPrices><bes tAvailableToLay Prices><price
amountUnmat ched="62.16">4. 34</price><price
amountUnmat ched="228.21">4 .36</price><price
amountUnmat ched="570.76">4 .38</price></bestAvailableTo LayPrices></selection><sele ction
id="658440" ><name>Hand 2</name><resource
href="https ://api.games.betfa ir.com/rest/v1/selection/tradeActivity?u sername=kingten clubs&amp;marke tId=5627743&amp ;selectionId=65 8440"
responseTyp e="selectionTra deActivity" title="Trade Activity"
/><status>IN_PLA Y</status><amountM atched>79.38</amountMatched>< bestAvailableTo BackPrices><pri ce
amountUnmat ched="263.15">2 .94</price><price
amountUnmat ched="1109.2">2 .93</price><price
amountUnmat ched="1288.64"> 2.91</price></bestAvailableTo BackPrices><bes tAvailableToLay Prices><price
amountUnmat ched="183.92">2 .97</price><price
amountUnmat ched="294.17">2 .98</price><price
amountUnmat ched="836.12">2 .99</price></bestAvailableTo LayPrices></selection><sele ction
id="658441" ><name>Hand 3</name><resource
href="https ://api.games.betfa ir.com/rest/v1/selection/tradeActivity?u sername=kingten clubs&amp;marke tId=5627743&amp ;selectionId=65 8441"
responseTyp e="selectionTra deActivity" title="Trade Activity"
/><status>IN_PLA Y</status><amountM atched>173.92</amountMatched>< bestAvailableTo BackPrices><pri ce
amountUnmat ched="50.6">7.8 </price><price
amountUnmat ched="447.26">7 .75</price><price
amountUnmat ched="487.0">7. 7</price></bestAvailableTo BackPrices><bes tAvailableToLay Prices><price
amountUnmat ched="169.6">7. 9</price><price
amountUnmat ched="314.44">7 .95</price><price
amountUnmat ched="468.72">8 .0</price></bestAvailableTo LayPrices></selection><sele ction
id="658442" ><name>Hand 4</name><resource
href="https ://api.games.betfa ir.com/rest/v1/selection/tradeActivity?u sername=kingten clubs&amp;marke tId=5627743&amp ;selectionId=65 8442"
responseTyp e="selectionTra deActivity" title="Trade Activity"
/><status>IN_PLA Y</status><amountM atched>131.4</amountMatched>< bestAvailableTo BackPrices><pri ce
amountUnmat ched="381.11">3 .28</price><price
amountUnmat ched="766.84">3 .26</price><price
amountUnmat ched="1157.4">3 .24</price></bestAvailableTo BackPrices><bes tAvailableToLay Prices><price
amountUnmat ched="230.47">3 .32</price><price
amountUnmat ched="973.0">3. 34</price><price
amountUnmat ched="1116.04"> 3.36</price></bestAvailableTo LayPrices></selection></selections></market></markets></game></channel></channelSnapshot >
>
>
>
"Stephany Young" <noone@localhos twrote in message
news:e%**** ************@TK 2MSFTNGP04.phx. gbl...
>Given the XML that you have provided, the following produces the
>results as shown (I saved the XML to a file for the purpose of the
>exercise ):
>>
> Dim _doc As New XmlDocument
> _doc.Load("chan nelSnapshot.xml ")
> Dim _node As XmlNode = _doc.SelectSing leNode("//channel/status")
> Console.WriteLi ne(_node.InnerT ext)
> _node = _doc.SelectSing leNode("//channel/game")
> Console.WriteLi ne(_node.Attrib utes("id").Valu e)
> _node = _doc.SelectSing leNode("//channel/game/round")
> Console.WriteLi ne(_node.InnerT ext)
> _node =
>_doc.Selec tSingleNode("//channel/game/bettingWindowPe rcentageComplet e")
> Console.WriteLi ne(_node.InnerT ext)
>>
> Results
> -------
> RUNNING
> 1817283
> 3
> 24
>>
>If you change the XPath expressions or change the scope of the
>SelectSing leNode method, then it will not work.
>>
>Out of interest, what do you get if you execute the equivalent of:
>>
> Console.WriteLi ne(_doc.OuterXm l)
>>
>immediatel y after 'loading' the XmlDocument object from the
>StreamRead er object?
>>
>>
>"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
>news:%2*** *************@T K2MSFTNGP04.phx .gbl...
>>And I did say, i have tried many variatons including yours but it
>>did not work
>>>
>>"Stepha ny Young" <noone@localhos twrote in message
>>news:Oq** ************@TK 2MSFTNGP02.phx. gbl...
>>>Again with the changing of it!!!!!!!
>>>>
>>>I DID NOT say:
>>>>
>>> objDoc.SelectSi ngleNode("//channelSnaphot/channel/status")
>>>>
>>>I DID say:
>>>>
>>> objDoc.SelectSi ngleNode("//channel/status")
>>>>
>>>I don't know why you persist in inserting channelSnaphot/ into the
>>>query!
>>>>
>>>//channel/status means find me the first element called status that
>>>is a descendant of an element called channel that occurs anywhere
>>>in the document.
>>>>
>>>>
>>>>
>>>"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
>>>news:u%* *************** @TK2MSFTNGP06.p hx.gbl...
>>>>Good afternoon, yes i am a newby so pls keep it simple.
>>>>>
>>>>Yesterd ay I started a small project where I have to make an API
>>>>call and receive back from that the long xml transcript down
>>>>below .
>>>>>
>>>>Now, not knowing about XML I have experienced one or 2 issues.
>>>>>
>>>>Firstly , this is the code I have created to make the call and then
>>>>extra ct a few bits of information:
>>>>>
>>>>'Crea te the web request
>>>>>
>>>>Dim request As HttpWebRequest =
>>>>WebRequ est.Create(https://api.games.betfair.com/rest/v...sername=******)
>>>>request .Method = "GET"
>>>>request .Timeout = 5000
>>>>>
>>>>'Add headers to the web request
>>>>request .Headers.Add("g amexAPIAgent",
>>>>******* *@hotmail.co.uk .myGames.4.0)
>>>>request .Headers.Add("g amexAPIAgentIns tance",
>>>>"0d69ee 8290ee2f9b336c1 f060e3497a5")
>>>>request .Headers.Add("g amexAPIPassword ", "*******")
>>>>>
>>>>'Get response
>>>>Dim response As HttpWebResponse = request.GetResp onse()
>>>>>
>>>>Dim reader As StreamReader = New
>>>>StreamR eader(response. GetResponseStre am)
>>>>Dim objDoc As XmlReader = XmlReader.Creat e(reader)
>>>>objDoc. MoveToContent()
>>>>objDoc. ReadToFollowing ("status")
>>>>Me.Stat usTextBox.Text = objDoc.ReadElem entContentAsStr ing
>>>>objDoc. ReadToFollowing ("game")
>>>>Me.Game IDTextBox.Text = objDoc.GetAttri bute("id").ToSt ring
>>>>objDoc. ReadToFollowing ("round")
>>>>Me.Roun dNumberTextBox. Text = objDoc.ReadElem entContentAsStr ing
>>>>objDoc. ReadToFollowing ("bettingWindow PercentageCompl ete")
>>>>Me.Perc entageTimeTextB ox.Text = objDoc.ReadElem entContentAsStr ing
>>>>CallLab el.Text = "captured"
>>>>Catch ex As Exception
>>>>CallLab el.Text = "not captured"
>>>>End Try
>>>>>
>>>>For the most part this works fine but what I would rather do, is
>>>>point directly to the nodes listed in the code directly, now I
>>>>have some tell me "//channelSnaphot/channel/status" is the way to
>>>>go through a XMLSelectSingle Node, but I have tried and failed
>>>>using that method.
>>>>>
>>>>Is there anyone out the who can improve on my code so I can make
>>>>20 or 30 direct calls to the nodes in the Stream Response I
>>>>recei ve below? I am pleased to say the layout of the response will
>>>>never change so thats not an issue i need to address.
>>>>>
>>>>Regar ds
>>>>>
>>>>API Call Returns the following:
>>>><channe lSnapshot>
>>>> <channel gameType="POKER " id="1444074" name="Exchange
>>>>Poker Texas
>>>>Hold'em ">
>>>> <status>RUNNING </status>
>>>> <game id="1817283">
>>>> <round>3</round>
>>>> <bettingWindowT ime>45</bettingWindowTi me>
>>>>>
>>>><bettin gWindowPercenta geComplete>24</bettingWindowPe rcentageComplet e>
>>>> <gameData>
>>>> <object name="Hand 1">
>>>> <description>On e Pair, Fours, Ace
>>>>High,
>>>>with Q, 8 Kickers</description>
>>>> <status>IN_PLAY </status>
>>>> <property name="Card 1"
>>>>value=" 20"/>
>>>> <property name="Card 2"
>>>>value=" 29"/>
>>>> </object>
>>>> <object name="Hand 2">
>>>> <description>On e Pair, Sixes, Ace
>>>>High</description>
>>>> <status>IN_PLAY </status>
>>>> <property name="Card 1"
>>>>value=" 5"/>
>>>> <property name="Card 2"
>>>>value=" 44"/>
>>>> </object>
>>>> <object name="Hand 3">
>>>> <description>On e Pair, Fours, Ace
>>>>High,
>>>>with Q, 6 Kickers</description>
>>>> <status>IN_PLAY </status>
>>>> <property name="Card 1"
>>>>value=" 31"/>
>>>> <property name="Card 2"
>>>>value=" 42"/>
>>>> </object>
>>>> <object name="Hand 4">
>>>> <description>Ac e
>>>>High</description>
>>>> <status>IN_PLAY </status>
>>>> <property name="Card 1"
>>>>value=" 49"/>
>>>> <property name="Card 2"
>>>>value=" 45"/>
>>>> </object>
>>>> <object name="Community Cards">
>>>> <description/>
>>>> <status>N/A</status>
>>>> <property name="Card 1"
>>>>value=" 3"/>
>>>> <property name="Card 2"
>>>>value=" 13"/>
>>>> <property name="Card 3"
>>>>value=" 11"/>
>>>> <property name="Card 4" value="NOT
>>>>AVAILAB LE"/>
>>>> <property name="Card 5" value="NOT
>>>>AVAILAB LE"/>
>>>> </object>
>>>> </gameData>
>>>> <markets currency="GBP">
>>>> <market id="5615051">
>>>> <status>ACTIV E</status>
>>>>>
>>>><commis sionRate>2.5</commissionRate>
>>>> <marketType>WIN _ONLY</marketType>
>>>> <selections type="MainBets" >
>>>> <selection id="658439">
>>>> <name>Hand 1</name>
>>>> <resource
>>>>href="h ttps://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8439"
>>>>respons eType="selectio nTradeActivity" title="Trade Activity"/>
>>>>>
>>>><status >IN_PLAY</status>
>>>>>
>>>><amount Matched>22.74</amountMatched>
>>>>>
>>>><bestAv ailableToBackPr ices>
>>>> <price
>>>>amountU nmatched="204.4 2">6.6</price>
>>>> <price
>>>>amountU nmatched="381.6 4">6.55</price>
>>>> <price
>>>>amountU nmatched="576.9 2">6.5</price>
>>>>>
>>>></bestAvailableTo BackPrices>
>>>>>
>>>><bestAv ailableToLayPri ces>
>>>> <price
>>>>amountU nmatched="74.6" >6.7</price>
>>>> <price
>>>>amountU nmatched="504.7 4">6.75</price>
>>>> <price
>>>>amountU nmatched="551.4 4">6.8</price>
>>>>>
>>>></bestAvailableTo LayPrices>
>>>> </selection>
>>>> <selection id="658440">
>>>> <name>Hand 2</name>
>>>> <resource
>>>>href="h ttps://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8440"
>>>>respons eType="selectio nTradeActivity" title="Trade Activity"/>
>>>>>
>>>><status >IN_PLAY</status>
>>>>>
>>>><amount Matched>88.68</amountMatched>
>>>>>
>>>><bestAv ailableToBackPr ices>
>>>> <price
>>>>amountU nmatched="306.6 6">1.72</price>
>>>> <price
>>>>amountU nmatched="4127. 36">1.71</price>
>>>> <price
>>>>amountU nmatched="59.63 ">1.7</price>
>>>>>
>>>></bestAvailableTo BackPrices>
>>>>>
>>>><bestAv ailableToLayPri ces>
>>>> <price
>>>>amountU nmatched="99.98 ">1.73</price>
>>>> <price
>>>>amountU nmatched="2188. 96">1.74</price>
>>>> <price
>>>>amountU nmatched="2200. 77">1.75</price>
>>>>>
>>>></bestAvailableTo LayPrices>
>>>> </selection>
>>>> <selection id="658441">
>>>> <name>Hand 3</name>
>>>> <resource
>>>>href="h ttps://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8441"
>>>>respons eType="selectio nTradeActivity" title="Trade Activity"/>
>>>>>
>>>><status >IN_PLAY</status>
>>>>>
>>>><amount Matched>102.9</amountMatched>
>>>>>
>>>><bestAv ailableToBackPr ices>
>>>> <price
>>>>amountU nmatched="17.99 ">45.0</price>
>>>> <price
>>>>amountU nmatched="140.4 ">44.5</price>
>>>> <price
>>>>amountU nmatched="2.19" >44.0</price>
>>>>>
>>>></bestAvailableTo BackPrices>
>>>>>
>>>><bestAv ailableToLayPri ces>
>>>> <price
>>>>amountU nmatched="33.52 ">46.0</price>
>>>> <price
>>>>amountU nmatched="53.76 ">46.5</price>
>>>> <price
>>>>amountU nmatched="79.76 ">47.0</price>
>>>>>
>>>></bestAvailableTo LayPrices>
>>>> </selection>
>>>> <selection id="658442">
>>>> <name>Hand 4</name>
>>>> <resource
>>>>href="h ttps://api.games.betfa ir.com/rest/v1/selection/tradeActivity?m arketId=5615051 &selectionId=65 8442"
>>>>respons eType="selectio nTradeActivity" title="Trade Activity"/>
>>>>>
>>>><status >IN_PLAY</status>
>>>>>
>>>><amount Matched>1020.0</amountMatched>
>>>>>
>>>><bestAv ailableToBackPr ices>
>>>> <price
>>>>amountU nmatched="158.0 7">4.0</price>
>>>> <price
>>>>amountU nmatched="198.1 9">3.98</price>
>>>> <price
>>>>amountU nmatched="631.2 8">3.96</price>
>>>>>
>>>></bestAvailableTo BackPrices>
>>>>>
>>>><bestAv ailableToLayPri ces>
>>>> <price
>>>>amountU nmatched="103.8 4">4.06</price>
>>>> <price
>>>>amountU nmatched="612.7 2">4.08</price>
>>>> <price
>>>>amountU nmatched="914.6 ">4.1</price>
>>>>>
>>>></bestAvailableTo LayPrices>
>>>> </selection>
>>>> </selections>
>>>> </market>
>>>> </markets>
>>>> </game>
>>>> </channel>
>>>> </channelSnapshot >
>>>>>
>>>>>
>>>>
>>>
>>>
>>
>
>

Feb 22 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
3696
by: Stuart | last post by:
Hi All, I got a challenge to make the same APS/Script/Html run on different web roots. I can not use relative pathing in a lot of cases. We use lots of included files so depending on where that file is running, the pathing in those included files varies. So we do a lot of absolute pathing. Example: Instead of Mappath("../../../_scripts/menu/mymenuscript.js") we use mappath("/_scripts/menu/mymenuscript.js"). In one case, the code is...
0
1162
by: clintonG | last post by:
I've used plenty of ../../css/styles.css pathing but some hosting providers disable pathing. I also use ~/css/styles.css when needing to provide access to the css directory when it is in the root of an application which needs to be accessed from any number of directories below that point. Apparently the tilde pathing operator does not support providing access to the css directory as shown in this diagram.... VirtualApplication Root
5
3114
by: Patient Guy | last post by:
In my reading of the Strict and Transitional DTD for HTML 4.0, the table row (TR) elements are contained within table section elements: THEAD, TFOOT, and TBODY. The table section elements are the defined contents of the TABLE element. The TR element is not defined as an "immediate" or "direct" contained element of TABLE. Given that
1
1699
by: Roger | last post by:
I need to edit the IIS 6.0 config file (metabase.xml) and had a go with this code, trying to get a list of all defined websites, and write their name to console, but it does not seem to work, would appreciate any pointers: ----------- Try Dim doc As New XmlDocument Dim nodelist As XmlNodeList Dim node As XmlNode
0
8474
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8819
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8669
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7428
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6222
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5692
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4222
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4403
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1807
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.