Link to home
Start Free TrialLog in
Avatar of VirusMinus
VirusMinusFlag for Australia

asked on

XmlTextReader screen scrape get xml element content

Im trying to grab xml off a web page and get the content of one particular element.

i have a page xml.asp that outputs the following xml:

<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="../quote_xml.css"?>
<quotes>
            <quote>
                        <exchange>XYZ</exchange>
                        <symbol>ABC</symbol>
                        <description>Lorem Ipsum</description>
                        <lastprice>32.500</lastprice>
                        <timestamp>
                                    <date>20061201</date>
                                    <time>105500</time>
                        </timestamp>
            </quote>
</quotes>

in my vb.net code i have this so far:

Imports System.XML

Dim xtr as New XmlTextReader("http://www.mypage.com/xml.asp")

xtr.MoveToContent()
xtr.MoveToElement("lastprice") 'error here!

'how can i get the lastprice element's content i.e. 32.500 ?
'i'm unsure of how to use the XmlTextReader's methods, can someone point out good examples of its usage?




Avatar of Hillwaaa
Hillwaaa
Flag of Australia image

Hi VirusMinus,

Check out: http://www.codeproject.com/vb/net/parsefilecode.asp

it has a good example on parsing xml.

Cheers,
Hillwaaa
Avatar of VirusMinus

ASKER

Thanks, i saw that page already. any ideas on my particular problem. I'm thinking there's got to be a simpler way to do it as compared to what the page shows, just to get one element's content.
ASKER CERTIFIED SOLUTION
Avatar of Hillwaaa
Hillwaaa
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial