W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2005

VB 6.0 XML parsing

From: gaurav verma <citius21j@yahoo.com>
Date: Mon, 9 May 2005 18:55:00 -0700 (PDT)
Message-ID: <20050510015500.21770.qmail@web31303.mail.mud.yahoo.com>
To: www-dom@w3.org
I want to code a general XML parser which parses XML files into a textbox in VB.
I am able to parse all the nodes and child nodes except the ones with attribute..Please see below for my input XML file...code...output and the desired output...
- <address>


  <address>Your house</address> 

  <tell>you tell me 12321</tell> 

- <addresstt hi="ho">



Output I am getting now
      address:Your house
      tell:you tell me 12321
Desired Output
address:your house
tell:you tell me 12321
As you see with my code I can't capture the items in BOLD....
Here is my code...
Option Explicit
Dim xml_document As DOMDocument
Dim xDoc As MSXML.DOMDocument
Private m_AppPath As String
Private Sub LoadValues()

   ' Load the document.
   Set xDoc = New MSXML.DOMDocument
    xDoc.Load m_AppPath & "output.xml"
    ' If the file doesn't exist, then
    ' xml_document.documentElement is Nothing.
    If xDoc.documentElement Is Nothing Then
        ' The file doesn't exist. Do nothing.
        Exit Sub
    End If
    ' Find the Values section.

End Sub
Public Sub DisplayNode(ByRef Nodes As MSXML.IXMLDOMNodeList, _
   ByVal Indent As Integer)
    Dim currNode As IXMLDOMNode
   Dim xNode As MSXML.IXMLDOMNode
   Indent = Indent + 2
   For Each xNode In Nodes
      If xNode.nodeType = NODE_TEXT Then
         Text1.Text = Text1.Text & Space$(Indent) & xNode.parentNode.nodeName & _
            ":" & xNode.nodeValue & vbCrLf
      End If
If xNode.nodeType = NODE_CDATA_SECTION Then
Text1.Text = Text1.Text & xNode.nodeValue & vbCrLf
End If
      If xNode.hasChildNodes Then
         DisplayNode xNode.childNodes, Indent
                  End If
     Next xNode
End Sub
Private Sub Form_Load()
    ' Get the application's startup path.
    m_AppPath = App.Path
    If Right$(m_AppPath, 1) <> "\" Then m_AppPath = m_AppPath & "\"
    ' Load the values.
    DisplayNode xDoc.childNodes, 0
End Sub
I want to develop a generic parser so I dont want to use getattribute('hi')....

This is my first post here...and I am a newbie to VB and XML....Any help will be greatly appreciated...
Looking forward to your help....

Do you Yahoo!?
 Yahoo! Small Business - Try our new resources site! 
Received on Tuesday, 10 May 2005 04:23:41 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:12 UTC