This code is used to traverse an XML map to convert a hashtable into data to be exported to a CSV file.
Why any of this is necessary, I have no idea; I just though you guys might appreciate the variable names in this function
Private Sub ParseChildNode(ByVal xmlDataNode As XmlNode, ByVal parentNodeName As String, ByVal grandParentNodeName As String, ByVal grandGrandParentNodeName As String, ByVal superGrandGrandParentNodeName As String, ByVal parentSix As String, ByVal parentSeven As String)
Dim childNode As XmlNode
Dim childIndex As Int32
Dim columnNo As Int32
Dim subChildIndex As Int32
Dim noOfChildNodex As Int32 = xmlDataNode.ChildNodes.Count
If (Not xmlDataNode.Attributes Is Nothing) Then
If (Not xmlDataNode.Attributes.ItemOf("column") Is Nothing) Then
columnNo = Convert.ToInt32(xmlDataNode.Attributes.ItemOf("column").Value)
If (xmlDataNode.Name = "attribute") Then
If (inputHashtable.Contains(parentSeven + "." + parentSix + "." + superGrandGrandParentNodeName + "." + grandGrandParentNodeName + "." + grandParentNodeName + "." + parentNodeName + "." + xmlDataNode.Attributes.ItemOf("name").Value)) Then
listData.Insert(columnNo - 1, inputHashtable.Item(parentSeven + "." + parentSix + "." + superGrandGrandParentNodeName + "." + grandGrandParentNodeName + "." + grandParentNodeName + "." + parentNodeName + "." + xmlDataNode.Attributes.ItemOf("name").Value))
Else
'Enter null value
listData.Insert(columnNo - 1, "")
End If
Else
If (inputHashtable.Contains(parentSeven + "." + parentSix + "." + superGrandGrandParentNodeName + "." + grandGrandParentNodeName + "." + grandParentNodeName + "." + parentNodeName + "." + xmlDataNode.Name)) Then
listData.Insert(columnNo - 1, inputHashtable.Item(parentSeven + "." + parentSix + "." + superGrandGrandParentNodeName + "." + grandGrandParentNodeName + "." + grandParentNodeName + "." + parentNodeName + "." + xmlDataNode.Name))
Else
'Enter null value
listData.Insert(columnNo - 1, "")
End If
End If
End If
End If
parentSeven = parentSix
parentSix = superGrandGrandParentNodeName
superGrandGrandParentNodeName = grandGrandParentNodeName
grandGrandParentNodeName = grandParentNodeName
grandParentNodeName = parentNodeName
For childIndex = 0 To noOfChildNodex - 1
childNode = xmlDataNode.ChildNodes.Item(childIndex)
parentNodeName = xmlDataNode.Name
If (Not childNode.Attributes.ItemOf("column") Is Nothing) Then
columnNo = Convert.ToInt32(childNode.Attributes.ItemOf("column").Value)
If (childNode.Name = "attribute") Then
If (inputHashtable.Contains(parentSeven + "." + parentSix + "." + superGrandGrandParentNodeName + "." + grandGrandParentNodeName + "." + grandParentNodeName + "." + parentNodeName + "." + childNode.Attributes.ItemOf("name").Value)) Then
listData.Insert(columnNo - 1, inputHashtable.Item(parentSeven + "." + parentSix + "." + superGrandGrandParentNodeName + "." + grandGrandParentNodeName + "." + grandParentNodeName + "." + parentNodeName + "." + childNode.Attributes.ItemOf("name").Value))
Else
'Enter null value
listData.Insert(columnNo - 1, "")
End If
Else
If (inputHashtable.Contains(parentSeven + "." + parentSix + "." + superGrandGrandParentNodeName + "." + grandGrandParentNodeName + "." + grandParentNodeName + "." + parentNodeName + "." + childNode.Name)) Then
listData.Insert(columnNo - 1, inputHashtable.Item(parentSeven + "." + parentSix + "." + superGrandGrandParentNodeName + "." + grandGrandParentNodeName + "." + grandParentNodeName + "." + parentNodeName + "." + childNode.Name))
Else
'Enter null value
listData.Insert(columnNo - 1, "")
End If
End If
End If
If (childNode.HasChildNodes) Then
For subChildIndex = 0 To childNode.ChildNodes.Count - 1
If (parentNodeName = "#document") Then
ParseChildNode(childNode.ChildNodes.Item(subChildIndex), childNode.Name, "", "", "", "", "")
Else
ParseChildNode(childNode.ChildNodes.Item(subChildIndex), childNode.Name, parentNodeName, grandParentNodeName, grandGrandParentNodeName, superGrandGrandParentNodeName, parentSix)
End If
Next
End If
Next childIndex
End Sub