Reading data from an XML file in VB6.0

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anupkossambe
    New Member
    • Mar 2007
    • 13

    Reading data from an XML file in VB6.0

    How do i read data from an XML file in VB6.0(Parse it) and display it in a TextField on the VB6.0 form? I would be highly grateful for any help on that.
  • vijaydiwakar
    Contributor
    • Feb 2007
    • 579

    #2
    Originally posted by anupkossambe
    How do i read data from an XML file in VB6.0(Parse it) and display it in a TextField on the VB6.0 form? I would be highly grateful for any help on that.
    no. but u may create it
    that means create it by urself
    Good Luck

    Comment

    • vijaydiwakar
      Contributor
      • Feb 2007
      • 579

      #3
      Originally posted by vijaydiwakar
      no. but u may create it
      that means create it by urself
      Good Luck
      try to use MSXML3.dll

      Comment

      • anupkossambe
        New Member
        • Mar 2007
        • 13

        #4
        I am new to visual basic and i needed the source code to load a file say "abc.xml" stored in my C drive, parse it's tags and display the data on the vb6.0 form.

        Comment

        • vijaydiwakar
          Contributor
          • Feb 2007
          • 579

          #5
          Originally posted by anupkossambe
          I am new to visual basic and i needed the source code to load a file say "abc.xml" stored in my C drive, parse it's tags and display the data on the vb6.0 form.
          dear the xml concept works very well in .net try it to code it in .net

          Comment

          • anupkossambe
            New Member
            • Mar 2007
            • 13

            #6
            by the way i found the solution. For an xml file having a root node as "note" and child nodes as to,from,heading and body the following code will parse it for you


            Private Sub Readxml()

            Dim XmlDoc As New DOMDocument30
            Dim nodlst As IXMLDOMNodeList
            '============== ===========
            'Declaring node variable for the child elements
            Dim nod As IXMLDOMNode

            '============== ============
            Dim nodCnt As Long
            Dim Data() As String

            XmlDoc.async = False

            'Loading the XML file on C drive
            If XmlDoc.Load("fi le:///C:/anup.xml") Then



            '============== ============
            'Assigning root node to the node list variable
            Set nodlst = XmlDoc.selectNo des("/note")


            ReDim Data(nodlst.len gth)

            For nodCnt = 0 To nodlst.length - 1

            Set nod = nodlst(nodCnt). selectSingleNod e("to")
            Data(nodCnt) = nod.Text

            Set nod = nodlst(nodCnt). selectSingleNod e("from")
            '============== =============
            'Appending data inside "from" to "to"
            Data(nodCnt) = Data(nodCnt) & vbTab & nod.Text

            Set nod = nodlst(nodCnt). selectSingleNod e("heading")

            'Appending data inside "to,from" to "heading"
            Data(nodCnt) = Data(nodCnt) & vbTab & nod.Text

            Set nod = nodlst(nodCnt). selectSingleNod e("body")

            'Appending data inside "to,from,headin g" to "body"
            Data(nodCnt) = Data(nodCnt) & vbTab & nod.Text


            Debug.Print nodCnt, Data(nodCnt)

            Next nodCnt
            Else


            MsgBox ("Can't load file")
            End If

            End Sub

            Comment

            • anupkossambe
              New Member
              • Mar 2007
              • 13

              #7
              Thanks anyways Vijay

              Comment

              • moarefian
                New Member
                • Mar 2007
                • 1

                #8
                Originally posted by anupkossambe
                How do i read data from an XML file in VB6.0(Parse it) and display it in a TextField on the VB6.0 form? I would be highly grateful for any help on that.
                How do i read data from an XML file in VB6.0(Parse it) and display it in a TextField on the VB6.0 form? I would be highly grateful for any help on that

                Comment

                • madand
                  New Member
                  • Apr 2012
                  • 1

                  #9
                  Here I have attached anup.xml that is used in code.

                  <note>
                  <to>Tove</to>
                  <from>Jani</from>
                  <heading>Remind er</heading>
                  <body>Don't forget me this weekend!</body>
                  </note>

                  Comment

                  Working...