Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Reading XML
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Reading XML

 Post Reply Post Reply
Author
Stevo View Drop Down
Newbie
Newbie
Avatar

Joined: 11 November 2002
Location: Australia
Status: Offline
Points: 37
Post Options Post Options   Thanks (0) Thanks(0)   Quote Stevo Quote  Post ReplyReply Direct Link To This Post Topic: Reading XML
    Posted: 13 April 2003 at 8:40am

Hi there!

Just wondering if anyone can help me out here... I am trying to read XML using an ASP.NET page.  Basically, the XML file stores a whole heap of values, and we want to read them in to allow for easy updates.  Trouble is, i am having trouble finding much info on reading xml into variables.  Most examples use datagrid, and from what i've seen of that, it looks pretty limited - more for just outputting to the screen.

If anyone can shed any light, or point me to a good source of info on the net, that would be really great and muchas appreciated.

Thanks heaps,
Steve

Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 13 April 2003 at 9:32am

Simple. Lets say you got an xml file as follows:
<?xml version="1.0" encoding="utf-8" ?>
<myroot>
<myvalue1 value="Whatever" />
<myvalue2 value="not sure" />
</myroot>

You can read the value of myvalue1 into a variable as follows:

Dim reader As XmlTextReader = New XmlTextReader("c:\xmlfile.xml")
        While reader.Read()
            If XmlNodeType.Element Then
                If reader.Name = "myvalue1" Then
                    reader.MoveToAttribute("value")
                    myvar = reader.Value                'Make sure to declare
                    reader.Close()
                End If
            End If
        End While

Back to Top
Stevo View Drop Down
Newbie
Newbie
Avatar

Joined: 11 November 2002
Location: Australia
Status: Offline
Points: 37
Post Options Post Options   Thanks (0) Thanks(0)   Quote Stevo Quote  Post ReplyReply Direct Link To This Post Posted: 16 April 2003 at 2:45am

Thanks Michael,

That looks great.  I haven't had a chance to try it yet, as i am doing another sub-project right at the moment, but i will give it a go as soon as i can and let you know.  Hopefully, i will be able to get my brain around it for a multiple tiered XML file.

Many thanks,
Steve
Smile

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.