473,762 Members | 7,418 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML Help

OK this might be long winded by want to show you everything I am doing.

Down below is the result I get from an API Call to a website called Betfair.

The following is some code I am trying, but I have also tried many different
variations.
Dim response As HttpWebResponse = request.GetResp onse()

'Get the response stream
Dim reader As StreamReader = New StreamReader(re sponse.GetRespo nseStream)

Dim objDoc As New System.Xml.XmlD ocument
objDoc.Load(rea der)

Dim Node As XmlNode = objDoc.SelectSi ngleNode("/channel/status")
MsgBox(Node.Val ue)

I am trying to the word "RUNNING" from within line 3 of the call but instead
I am getting NullReferenceEx ception.
I want to keep my code as simple as possible and I will want to pull other
information such as the id attribute from line 4 of the call.

Can anyone help?
MC
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
4 1369
Your:

Dim Node As XmlNode = objDoc.SelectSi ngleNode("/channel/status")

is the issue. The SelectSingleNod e method is relative to your current scope
(or position in the XmlDocument).

Your XPath expression is saying, get me the first status child element of
the first channel child element from where I am current at.

You are executing it from the objDoc object which does not have any channel
child elements. It has a single child element called channelSnapshot .

You can use this syntax:

Dim Node As XmlNode =
objDoc.Document Element.SelectS ingleNode("/channel/status")

which uses the same XPath expession but 'moves' the starting point to the
channelSnapshot element, or you can use this syntax:

Dim Node As XmlNode = objDoc.SelectSi ngleNode("//channel/status")

where the // indicates 'any descendant' element.

To get the value you then need to use:

Dim status As String = Node.InnerText

Like wise the next bit would be:
Node = objDoc.SelectSi ngleNode("//channel/game")

Dim id As String = Node.Attibbutes ("id").Value
"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
news:eD******** ******@TK2MSFTN GP06.phx.gbl...
OK this might be long winded by want to show you everything I am doing.

Down below is the result I get from an API Call to a website called
Betfair.

The following is some code I am trying, but I have also tried many
different
variations.
Dim response As HttpWebResponse = request.GetResp onse()

'Get the response stream
Dim reader As StreamReader = New StreamReader(re sponse.GetRespo nseStream)

Dim objDoc As New System.Xml.XmlD ocument
objDoc.Load(rea der)

Dim Node As XmlNode = objDoc.SelectSi ngleNode("/channel/status")
MsgBox(Node.Val ue)

I am trying to the word "RUNNING" from within line 3 of the call but
instead
I am getting NullReferenceEx ception.
I want to keep my code as simple as possible and I will want to pull other
information such as the id attribute from line 4 of the call.

Can anyone help?
MC
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
Stephany

Thanks for your help, I have made the changes and tried variations but
unfortunately I am still getting same.

This is the code I have now:

Dim response As HttpWebResponse = request.GetResp onse()

'Get the response stream

Dim reader As StreamReader = New StreamReader(re sponse.GetRespo nseStream)

Dim objDoc As New System.Xml.XmlD ocument

objDoc.Load(rea der)

Dim Node As XmlNode =
objDoc.Document Element.SelectS ingleNode("//channelSnapshot/channel/status")

MsgBox(Node.Inn erText)

Do you have a sample piece of code I could look at?

Regards

"Stephany Young" <noone@localhos twrote in message
news:uu******** ******@TK2MSFTN GP05.phx.gbl...
Your:

Dim Node As XmlNode = objDoc.SelectSi ngleNode("/channel/status")

is the issue. The SelectSingleNod e method is relative to your current
scope (or position in the XmlDocument).

Your XPath expression is saying, get me the first status child element of
the first channel child element from where I am current at.

You are executing it from the objDoc object which does not have any
channel child elements. It has a single child element called
channelSnapshot .

You can use this syntax:

Dim Node As XmlNode =
objDoc.Document Element.SelectS ingleNode("/channel/status")

which uses the same XPath expession but 'moves' the starting point to the
channelSnapshot element, or you can use this syntax:

Dim Node As XmlNode = objDoc.SelectSi ngleNode("//channel/status")

where the // indicates 'any descendant' element.

To get the value you then need to use:

Dim status As String = Node.InnerText

Like wise the next bit would be:
Node = objDoc.SelectSi ngleNode("//channel/game")

Dim id As String = Node.Attibbutes ("id").Value
"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
news:eD******** ******@TK2MSFTN GP06.phx.gbl...
>OK this might be long winded by want to show you everything I am doing.

Down below is the result I get from an API Call to a website called
Betfair.

The following is some code I am trying, but I have also tried many
different
variations.
Dim response As HttpWebResponse = request.GetResp onse()

'Get the response stream
Dim reader As StreamReader = New StreamReader(re sponse.GetRespo nseStream)

Dim objDoc As New System.Xml.XmlD ocument
objDoc.Load(re ader)

Dim Node As XmlNode = objDoc.SelectSi ngleNode("/channel/status")
MsgBox(Node.Va lue)

I am trying to the word "RUNNING" from within line 3 of the call but
instead
I am getting NullReferenceEx ception.
I want to keep my code as simple as possible and I will want to pull
other
information such as the id attribute from line 4 of the call.

Can anyone help?
MC
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
I gave you the code!!!!

Why did you change:

Dim Node As XmlNode = objDoc.SelectSi ngleNode("//channel/status")

to

Dim Node As XmlNode =
objDoc.Document Element.SelectS ingleNode("//channelSnapshot/channel/status")

Notice the difference!!!!! !
"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
Stephany

Thanks for your help, I have made the changes and tried variations but
unfortunately I am still getting same.

This is the code I have now:

Dim response As HttpWebResponse = request.GetResp onse()

'Get the response stream

Dim reader As StreamReader = New StreamReader(re sponse.GetRespo nseStream)

Dim objDoc As New System.Xml.XmlD ocument

objDoc.Load(rea der)

Dim Node As XmlNode =
objDoc.Document Element.SelectS ingleNode("//channelSnapshot/channel/status")

MsgBox(Node.Inn erText)

Do you have a sample piece of code I could look at?

Regards

"Stephany Young" <noone@localhos twrote in message
news:uu******** ******@TK2MSFTN GP05.phx.gbl...
>Your:

Dim Node As XmlNode = objDoc.SelectSi ngleNode("/channel/status")

is the issue. The SelectSingleNod e method is relative to your current
scope (or position in the XmlDocument).

Your XPath expression is saying, get me the first status child element of
the first channel child element from where I am current at.

You are executing it from the objDoc object which does not have any
channel child elements. It has a single child element called
channelSnapsho t.

You can use this syntax:

Dim Node As XmlNode =
objDoc.Documen tElement.Select SingleNode("/channel/status")

which uses the same XPath expession but 'moves' the starting point to the
channelSnapsho t element, or you can use this syntax:

Dim Node As XmlNode = objDoc.SelectSi ngleNode("//channel/status")

where the // indicates 'any descendant' element.

To get the value you then need to use:

Dim status As String = Node.InnerText

Like wise the next bit would be:
Node = objDoc.SelectSi ngleNode("//channel/game")

Dim id As String = Node.Attibbutes ("id").Value
"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
news:eD******* *******@TK2MSFT NGP06.phx.gbl.. .
>>OK this might be long winded by want to show you everything I am doing.

Down below is the result I get from an API Call to a website called
Betfair.

The following is some code I am trying, but I have also tried many
different
variations.
Dim response As HttpWebResponse = request.GetResp onse()

'Get the response stream
Dim reader As StreamReader = New
StreamReader( response.GetRes ponseStream)

Dim objDoc As New System.Xml.XmlD ocument
objDoc.Load(r eader)

Dim Node As XmlNode = objDoc.SelectSi ngleNode("/channel/status")
MsgBox(Node.V alue)

I am trying to the word "RUNNING" from within line 3 of the call but
instead
I am getting NullReferenceEx ception.
I want to keep my code as simple as possible and I will want to pull
other
information such as the id attribute from line 4 of the call.

Can anyone help?
MC
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
While i've tried many variations of what you said but I am still getting the
error.

I am now trying XMLReader.

I have got it reading but going through the XML and looking up "status" and
it is returning the contents of the each of the status elements within the
documents.

Next step, just give it what i need!!
"Stephany Young" <noone@localhos twrote in message
news:OM******** ******@TK2MSFTN GP06.phx.gbl...
>I gave you the code!!!!

Why did you change:

Dim Node As XmlNode = objDoc.SelectSi ngleNode("//channel/status")

to

Dim Node As XmlNode =
objDoc.Document Element.SelectS ingleNode("//channelSnapshot/channel/status")

Notice the difference!!!!! !
"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
>Stephany

Thanks for your help, I have made the changes and tried variations but
unfortunatel y I am still getting same.

This is the code I have now:

Dim response As HttpWebResponse = request.GetResp onse()

'Get the response stream

Dim reader As StreamReader = New StreamReader(re sponse.GetRespo nseStream)

Dim objDoc As New System.Xml.XmlD ocument

objDoc.Load(re ader)

Dim Node As XmlNode =
objDoc.Documen tElement.Select SingleNode("//channelSnapshot/channel/status")

MsgBox(Node.In nerText)

Do you have a sample piece of code I could look at?

Regards

"Stephany Young" <noone@localhos twrote in message
news:uu******* *******@TK2MSFT NGP05.phx.gbl.. .
>>Your:

Dim Node As XmlNode = objDoc.SelectSi ngleNode("/channel/status")

is the issue. The SelectSingleNod e method is relative to your current
scope (or position in the XmlDocument).

Your XPath expression is saying, get me the first status child element
of the first channel child element from where I am current at.

You are executing it from the objDoc object which does not have any
channel child elements. It has a single child element called
channelSnapsh ot.

You can use this syntax:

Dim Node As XmlNode =
objDoc.Docume ntElement.Selec tSingleNode("/channel/status")

which uses the same XPath expession but 'moves' the starting point to
the channelSnapshot element, or you can use this syntax:

Dim Node As XmlNode = objDoc.SelectSi ngleNode("//channel/status")

where the // indicates 'any descendant' element.

To get the value you then need to use:

Dim status As String = Node.InnerText

Like wise the next bit would be:
Node = objDoc.SelectSi ngleNode("//channel/game")

Dim id As String = Node.Attibbutes ("id").Value
"Mark Cooney" <ma**@mcooney.c o.ukwrote in message
news:eD****** ********@TK2MSF TNGP06.phx.gbl. ..
OK this might be long winded by want to show you everything I am doing.

Down below is the result I get from an API Call to a website called
Betfair.

The following is some code I am trying, but I have also tried many
different
variations .
Dim response As HttpWebResponse = request.GetResp onse()

'Get the response stream
Dim reader As StreamReader = New
StreamReader (response.GetRe sponseStream)

Dim objDoc As New System.Xml.XmlD ocument
objDoc.Load( reader)

Dim Node As XmlNode = objDoc.SelectSi ngleNode("/channel/status")
MsgBox(Node. Value)

I am trying to the word "RUNNING" from within line 3 of the call but
instead
I am getting NullReferenceEx ception.
I want to keep my code as simple as possible and I will want to pull
other
informatio n such as the id attribute from line 4 of the call.

Can anyone help?
MC
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

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

Similar topics

21
6554
by: Dave | last post by:
After following Microsofts admonition to reformat my system before doing a final compilation of my app I got many warnings/errors upon compiling an rtf file created in word. I used the Help Workshop program: hcw.exe that's included with Visual Basic. This exact same file compiled perfectly with no notes, warnings or errors prior to reformatting my system. Prior to the reformatting, I copied the help.rtf file onto a CD and checked the box to...
9
4411
by: Tom | last post by:
A question for gui application programmers. . . I 've got some GUI programs, written in Python/wxPython, and I've got a help button and a help menu item. Also, I've got a compiled file made with the microsoft HTML workshop utility, lets call it c:\path\help.chm. My question is how do you launch it from the GUI? What logic do I put behind the "help" button, in other words. I thought it would be os.spawnv(os.P_DETACH,...
6
4347
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing result in any way. Who can help me, I thank you very very much. list.cpp(main program) //-------------------------------------------------------------------------- - #pragma hdrstop #pragma argsused
3
3362
by: Colin J. Williams | last post by:
Python advertises some basic service: C:\Python24>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> With numarray, help gives unhelpful responses:
7
5384
by: Corepaul | last post by:
Missing Help Files When I enter "recordset" as the keyword and search the Visual Basic Help index, I get many topics of interest in the resulting list. But there isn't any information available from clicking on many of the available topics (mostly methods but some properties are also unavailable). This same problem occurs with many, if not most, keywords. Is there any way I can activate these "missing" help topics? HELP!
5
3279
by: Steve | last post by:
I have written a help file (chm) for a DLL and referenced it using Help.ShowHelp My expectation is that a developer using my DLL would be able to access this help file during his development time using "F1" help within the VB IDE. Is this expectation achievable In trying to test my help file in the IDE, I have a solution with 2 projects: the DLL and a tester. VB does not look for my help file; instead, it looks for path to my source code...
8
3235
by: Mark | last post by:
I have loaded Visual Studio .net on my home computer and my laptop, but my home computer has an abbreviated help screen not 2% of the help on my laptop. All the settings look the same on both including search the internet for help, but the help is worthless. Any ideas?
10
3364
by: JonathanOrlev | last post by:
Hello everybody, I wrote this comment in another message of mine, but decided to post it again as a standalone message. I think that Microsoft's Office 2003 help system is horrible, probably the worst I ever seen. I almost cannot find anything I need, including things I
1
6137
by: trunxnirvana007 | last post by:
'UPGRADE_WARNING: Array has a new behavior. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' 'UPGRADE_WARNING: Couldn't resolve default property of object Label. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"' Label = New Object(){Box1, Box2, Box3, Box4, Box5, Box6, Box7, Box8, Box9, Box10, Box11,...
0
2887
by: hitencontractor | last post by:
I am working on .NET Version 2003 making an SDI application that calls MS Excel 2003. I added a menu item called "MyApp Help" in the end of the menu bar to show Help-> About. The application calls MS Excel, so the scenario is that I am supposed to see the Excel Menu bar, FILE EDIT VIEW INSERT ... HELP. I am able to see the menu bar, but in case of Help, I see the Help of Excel and help of my application, both as a submenu of help. ...
0
9377
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10136
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9925
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9811
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...
1
7358
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
6640
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
5266
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...
3
3509
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
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.