Results 1 to 4 of 4

Thread: simple xml read

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2006
    Posts
    116

    simple xml read

    hello,

    I have a very simple xml file

    VB Code:
    1. <?xml version="1.0" ?>
    2. - <!-- This Is A List of Menu items
    3.   -->
    4. - <MyItems>
    5.   <ITEM TITLE="one" VALUE="one" />
    6.   <ITEM TITLE="two" VALUE="two" />
    7.   </MyItems>

    I would like to read each item within the file and add them to menu items,

    I think in .net 2.0 to use the xmlReader Class,

    could someone pelase suggest how to use that class in this situation, sorry im used to using the DOM vb6 object for this sort of thing.

    Many Thanks.

  2. #2
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: simple xml read

    Try the dataset object for read xml for you, I find it useful.
    VB Code:
    1. Protected Sub BindItems()
    2.         'read xml into dataset
    3.         Dim myDs As New DataSet
    4.         myDs.ReadXml("C:\Test.xml")
    5.         'bind data to listbox
    6.         ListBox1.DisplayMember = "TITLE"
    7.         ListBox1.ValueMember = "VALUE"
    8.         ListBox1.DataSource = myDs.Tables(0)
    9.     End Sub

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2006
    Posts
    116

    Re: simple xml read

    ops sorry this is asp.net using VB, thanks for the answer but how would i write this in the asp.net enviroment?

    thanks again.

  4. #4
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: simple xml read

    Just to clarify that is vb. When you say you want to add them to menu items, what do you mean?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width