Results 1 to 4 of 4

Thread: xml parsing choice

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    90

    xml parsing choice

    I've an xml parser that parses the attached "testXML.xml" file absolutely correctly. My question is i might have to parse the "[email protected] xml" file and won't it make my parser extremely complicated since, I have to keep track of where the contacts of a particular group end. I'm storing the contents in a treeview with the group names being the parent and the contacts being the children.

    So I wanted to get a feedback about parsing the "[email protected] xml" file or is it easy to do so.

    Here's the code for parser and i've attached the two xml files:

    VB Code:
    1. Private Sub LoadXMLNode()
    2.  
    3.    Dim xmlDoc As DOMDocument30
    4.    Dim intCounter As Integer
    5.    
    6.    Set xmlDoc = New MSXML2.DOMDocument30
    7.  
    8.    xmlDoc.Load ("C:\testXML.xml")
    9.    
    10.    Call RecurseChildNodes(xmlDoc, xmlDoc.childNodes)
    11.    
    12.    Set xmlDoc = Nothing
    13.      
    14. End Sub
    15.  
    16. Private Sub RecurseChildNodes(xmlDoc As MSXML2.DOMDocument30, childNode As IXMLDOMNodeList)
    17.    
    18.    
    19.    Dim CurrChildNode  As IXMLDOMNodeList
    20.    Dim intNodeCounter As Integer
    21.    
    22.    Dim Name As String
    23.    Dim childName As String
    24.    Dim thisNode As Node
    25.    Dim ctr As Integer
    26.    Dim childNum As Integer
    27.    ctr = 0
    28.    Set CurrChildNode = childNode
    29.    
    30.    For intNodeCounter = 0 To CurrChildNode.Length - 1
    31.      
    32.       If CurrChildNode.Length > 0 Then
    33.          Set childNode = CurrChildNode.Item(intNodeCounter).childNodes
    34.          If childNode.Length > 0 Then
    35.             RecurseChildNodes xmlDoc, childNode
    36.          
    37.             If CurrChildNode.Item(intNodeCounter).nodeName = "Group" Then
    38.                 Name = CurrChildNode.Item(intNodeCounter).Attributes.getNamedItem("type").nodeValue
    39.                 Set thisNode = TreeView1.Nodes.Add(, , Name, Name)
    40.                
    41.                 'ensure nodes displayed in alphabetical order
    42.                 thisNode.Sorted = True
    43.                 childNum = CurrChildNode.Item(intNodeCounter).childNodes.Length
    44.                 Do While ctr <> childNum
    45.                     childName = CurrChildNode.Item(intNodeCounter).childNodes(ctr).nodeTypedValue
    46.                     TreeView1.Nodes.Add Name, tvwChild, childName, childName
    47.                     ctr = ctr + 1
    48.                 Loop
    49.                 ctr = 0
    50.             End If
    51.              TreeView1.LineStyle = tvwRootLines
    52.            
    53.          End If
    54.       End If
    55.      
    56.    Next intNodeCounter
    57.    
    58. End Sub


    Thanks
    Attached Files Attached Files

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