Results 1 to 4 of 4

Thread: XML..Example please...

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2001
    Posts
    21

    Red face XML..Example please...

    Dear all,

    I have been spending so many time in searching a simple example of VB code to make modifications in XML file. Can anyone get me an example please..

    I have msxml3.0 and 4 beta with me installed in VB 6.0

    Please give me the example ASAP..

    thanks in advance..

  2. #2
    Member
    Join Date
    Feb 2000
    Location
    Kettering, Northants, England
    Posts
    56
    If you have MSXML v4 then use the language filter to only include VB, then search again. Try using document fragments.

  3. #3
    Fanatic Member riis's Avatar
    Join Date
    Nov 2001
    Posts
    551
    If you have MSXML v4 then use the language filter to only include VB, then search again.
    Of course you need to use the SDK which comes with the XML parser. You should be able to download it from Micro$oft's site.
    Of course I don't know what you want to do, but usually you should create an MSXML2.DOMDocument (which will represent your XML doc), read the XML file (with the load method), and set your doc's documentElement property (which is an IXMLDOMElement). From this point on you should be able to navigate through the XML tree structure.
    Don't be frightened by the tons of properties and methods I was really scared the first time I saw them. You'll get familiar with them soon enough.
    Good luck!

  4. #4
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Code:
    Option Explicit
    
    Private Sub Command1_Click()
        Dim xmlDOM As New DOMDocument
        Dim xmlNode As IXMLDOMNode
        Dim intIndex As Integer
        
        xmlDOM.appendChild xmlDOM.createElement("NAMES")
        For intIndex = 0 To List1.ListCount - 1
            Set xmlNode = xmlDOM.documentElement.appendChild(xmlDOM.createElement("NAME"))
            xmlNode.Text = List1.List(intIndex)
            Set xmlNode = Nothing
        Next
        Debug.Print xmlDOM.xml
        
    End Sub
    
    Private Sub Form_Load()
        List1.AddItem "Mike"
        List1.AddItem "John"
        List1.AddItem "Tom"
        List1.AddItem "Jerry"
    End Sub

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