Home All Groups Group Topic Archive Search About

How to read XML from a string variable??

Author
29 Oct 2006 12:02 AM
gwhite1
I am trying to get data from a web service. The service returns a
string like this:

<string
xmlns="http://www.webserviceX.NET/"><StockQuotes><Stock><Symbol>TEVA</Symbol><Last>33.25</Last><Date>10/27/2006</Date><Time>4:00pm</Time><Change>-0.37</Change><Open>33.62</Open><High>33.63</High><Low>33.19</Low><Volume>4080868</Volume><MktCap>25.426B</MktCap><PreviousClose>33.62</PreviousClose><PercentageChange>-1.10%</PercentageChange><AnnRange>29.22
- 45.91</AnnRange><Earns>0.084</Earns><P-E>400.24</P-E><Name>TEVA PHARM
INDS A</Name></Stock></StockQuotes></string>

I cannot figure how to extract the XML element (like LAST). I know I
could search the string for the data but I assume VB has a way to move
the string to a XML variable and then use something like variable.LAST
to get the last field. Any help would be appreciated!!!!

Sheila

Author
29 Oct 2006 2:05 AM
Tom Shelton
gwhi***@kc.rr.com wrote:
Show quoteHide quote
> I am trying to get data from a web service. The service returns a
> string like this:
>
> <string
> xmlns="http://www.webserviceX.NET/"><StockQuotes><Stock><Symbol>TEVA</Symbol><Last>33.25</Last><Date>10/27/2006</Date><Time>4:00pm</Time><Change>-0.37</Change><Open>33.62</Open><High>33.63</High><Low>33.19</Low><Volume>4080868</Volume><MktCap>25.426B</MktCap><PreviousClose>33.62</PreviousClose><PercentageChange>-1.10%</PercentageChange><AnnRange>29.22
> - 45.91</AnnRange><Earns>0.084</Earns><P-E>400.24</P-E><Name>TEVA PHARM
> INDS A</Name></Stock></StockQuotes></string>
>
> I cannot figure how to extract the XML element (like LAST). I know I
> could search the string for the data but I assume VB has a way to move
> the string to a XML variable and then use something like variable.LAST
> to get the last field. Any help would be appreciated!!!!
>
> Sheila

Shelia,

You could always load the xml string into an XmlDocument and use that
to navigate the xml.

--
Tom Shelton
Author
29 Oct 2006 2:09 PM
Mrozu
Tom Shelton wrote:
>
> You could always load the xml string into an XmlDocument and use that
> to navigate the xml.
>
> --
> Tom Shelton

or read it by dataset (by .ReadXML)

Mrozu