Results 1 to 3 of 3

Thread: Listing Titles from XML file

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2003
    Location
    Auckland
    Posts
    1,139

    Listing Titles from XML file

    this codes adds all records in one line, how can i seperate these to have one line each?????

    Code:
        Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
            ListBox1.Items.Clear()
    
            Dim nlx As New System.IO.StreamReader("C:\Documents and Settings\Owner\Desktop\newslist.xml")
            'XML reader
            Dim nx As New System.Xml.XmlTextReader(nlx)
            'XML doc
            Dim nlxd As New System.Xml.XmlDocument
            nlxd.Load(nx)
            Dim dd As String = nlxd.InnerText
    
    
            Dim x As Integer
            For x = 1 To 10
                ListBox1.Items.Add(dd)
            Next x
    
        End Sub

  2. #2
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    Re: Listing Titles from XML file

    I don't use XML at all so this is probably wrong but is the problem with the assignment of variable dd?

    Are you adding all text to a single string variable? If so, then you could parse the dd string variable into its single units (one per line) and then add those to the listbox.

    Alternatively, could you make dd a string array and add the inner text elements to each array element?
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Listing Titles from XML file

    Use the .SelectNodes() method of the XMLDocument object to retrieve a collection of nodes. You can then loop through that.

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