How to Use XML in VB6

Written by bobson st. pierre
  • Share
  • Tweet
  • Share
  • Email

XML is a markup language used for structuring and displaying data in a readable format. The language makes use of tags similar to HTML, but unlike HTML it offers more flexibility to define your own custom tags. VB6 is a programming language by Microsoft. VB6 makes use of objects called ActiveX controls. They provide VB6 programs with a number of capabilities, including writing XML documents within your program. To create and use XML documents in your VB6 program, you have to create a reference to its ActiveX control. Doing this is simple and takes just a few steps.

Skill level:

Other People Are Reading


  1. 1

    Open Visual Basic 6.

  2. 2

    Click "Standard EXE" from the new project list. You are now in the Visual Basic 6 programming environment. You should have a default main form on your screen to start adding your controls.

  3. 3

    Click "Project," "Add Module." This opens up a code module to start writing your Visual Basic programming code.

  4. 4

    Add a reference to the XML Object to your VB6 environment. Click "Project," and then click "References." This opens the References window. Scroll down and select "Microsoft XML, v2.6."

  5. 5

    Type the following code:

    Sub MyXMLDoc()

    Dim objXML As MSXML2.DOMDocument

    Dim strXML As String
    Set objXML = New MSXML2.DOMDocument
    ' put some XML in a variable --- the double quotes are
    ' VB6's string constant encoding of quotes

    strXML = "<example>

    <node name=""John Doe""/>

    <group name=""Programming"">

    <another value=""Jane Doe""/>


    If Not objXML.loadXML(strXML) Then
        Err.Raise objXML.parseError.errorCode, , objXML.parseError.reason
    End If

    End Sub

  6. 6

    Click "File" and "Save As" to save your Visual Basic project.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.