Results 1 to 4 of 4

Thread: read a .xml and list stuff

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,547

    read a .xml and list stuff

    ok how would i make an app that reads a .xml and displays its stuff for example inside the .xml is

    <name>bobby</name>
    <age>7</age>
    <name>bob</name>
    <age>23</age>

    how would i make it display

    bobby
    7
    bob
    23

    in a listbox?

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: read a .xml and list stuff

    Try this sample (was done some time ago) - you'll need to set reefrnces to MS XML 3.0:
    VB Code:
    1. Private Sub Command1_Click()
    2. '===================================
    3. Dim xml As New MSXML2.DOMDocument30
    4. Dim nds As MSXML2.IXMLDOMNodeList
    5. Dim nd As MSXML2.IXMLDOMNode
    6. Dim bRes As Boolean
    7.  
    8.     bRes = xml.Load(App.Path & "\test.xml")
    9.    
    10.     Set nds = xml.selectNodes(LCase("//name"))
    11.     Set nd = nds(0)
    12.    
    13.     Debug.Print nd.Text
    14.    
    15.     Set nds = xml.selectNodes(LCase("//text"))
    16.     Set nd = nds(0)
    17.    
    18.     Debug.Print nd.Text
    19.    
    20.     Set xml = Nothing
    21.     Set nds = Nothing
    22.     Set nd = Nothing
    23.  
    24. End Sub

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,547

    Re: read a .xml and list stuff

    Quote Originally Posted by RhinoBull
    Try this sample (was done some time ago) - you'll need to set reefrnces to MS XML 3.0:
    VB Code:
    1. Private Sub Command1_Click()
    2. '===================================
    3. Dim xml As New MSXML2.DOMDocument30
    4. Dim nds As MSXML2.IXMLDOMNodeList
    5. Dim nd As MSXML2.IXMLDOMNode
    6. Dim bRes As Boolean
    7.  
    8.     bRes = xml.Load(App.Path & "\test.xml")
    9.    
    10.     Set nds = xml.selectNodes(LCase("//name"))
    11.     Set nd = nds(0)
    12.    
    13.     Debug.Print nd.Text
    14.    
    15.     Set nds = xml.selectNodes(LCase("//text"))
    16.     Set nd = nds(0)
    17.    
    18.     Debug.Print nd.Text
    19.    
    20.     Set xml = Nothing
    21.     Set nds = Nothing
    22.     Set nd = Nothing
    23.  
    24. End Sub
    is there a way to do it without treeview

  4. #4

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