Results 1 to 10 of 10

Thread: [RESOLVED]Iterating XML Data to a Listview

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2009
    Posts
    12

    [RESOLVED]Iterating XML Data to a Listview

    Hi, all. I'm new here, but I always exhaust myself in research before I go asking for help with my code. What I'm actually doing is porting a program I wrote in AutoIT proprietary code over to vb by hand. I've really come far and have figured out out how to read/write data to an XML file, which was the biggest challenge. I'm having a little bit of a rough spot with iterating nodelist data and then adding it to a listview in order. Here's what I have within a sub that begins to pull data from the file.

    Code:
            Dim xmldoc As New System.Xml.XmlDocument()
                Dim nodelisttaken As XmlNodeList
                Dim nodelisttime As XmlNodeList
                Dim nodelistaccount As XmlNodeList
                Dim nodelistproduct As XmlNodeList
            Dim node As XmlNode
            Dim datestrip As String
            datestrip = "date" & Replace(MonthCalendar1.SelectionStart, Chr(47), Chr(46))
    
            xmldoc.Load(Application.StartupPath + "\data.xml")
    
    
                nodelisttaken = xmldoc.SelectNodes("/root/calllog/" & datestrip & "/*")
                nodelisttime = xmldoc.SelectNodes("/root/calllog/" & datestrip & "//time")
                nodelistaccount = xmldoc.SelectNodes("/root/calllog/" & datestrip & "//account")
                nodelistproduct = xmldoc.SelectNodes("/root/calllog/" & datestrip & "//product")
    
    
            For Each node In nodelisttime
    
                recorddump.Items.Add(node.InnerText)
    
    next
    So, as you can see, there are some predefined nodelists for the data that I want to grab. "recorddump" is my listview control name, so this very nicely takes the data I ask for and adds it to the first column. But the problems begin here. I read about adding data to columns and what I find is to use something like

    Code:
    dim object as listviewitem
    object = recorddump.items.add(node.innertext)
    with object
    .subitems.add(node.innertext)
    .subitems.add(node.innertext)
    .subitems.add(node.innertext)
    .imageindex = 0
    endwith
    This adds data a row at a time, which is what I want. But look at the data I'm feeding it, node.innertext. I have to iterate the specific nodelist before I can use node.innertext. Putting .subitems.add in the iteration just results in a huge mess. I thought about using a function to return the data and then drop the function name in there, but whenever I iterate within the function it only ever returns the first item (it iterates only once even though there are more than one interations). Hopefully someone can point me in the right direction, I don't need to be spoonfed the answer.
    Last edited by JetsterDajet; Apr 26th, 2009 at 04:32 PM.

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