VB 6.0 XML parsing

Hi,
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...
***********************
INPUT XML
***********************
- <address>
  <name>Jonty</name> 

  <petname>Popo</petname> 

  <address>Your house</address> 

  <tell>you tell me 12321</tell> 

- <addresstt hi="ho">
  <name1>Jippa</name1> 

  <tell1>9873</tell1> 

  </addresstt>


  </address>
 
*********************************************
Output I am getting now
******************************************
    name:Jonty
      petname:Popo
      address:Your house
      tell:you tell me 12321
        name1:Jippa
        tell1:9873
*********************************************
Desired Output
*********************************************
Address
name:Jonty
petname:Popo
address:your house
tell:you tell me 12321
Addresstt
hi:ho
name1:Jippa
tell1:9873
******************************************
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.
    LoadValues
      
    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....
 
Thanks






		
---------------------------------
Do you Yahoo!?
 Yahoo! Small Business - Try our new resources site! 

Received on Tuesday, 10 May 2005 04:23:41 UTC