Looking for tricks or methods of tracking the Node>Children>S ubChildren in an XML traverse.
Loading the XML isn't an issue, I have working code for that, it's determining the level of recursion as I traverse the tree, branches, twigs, leaves. What I need to do is relate back the Leaves to the Twigs to Branches
(yes, I know: Nodes, Child Nodes, Subchild nodes, etc...)
Tables I'm looking at (simplified)
[t_leaves]
[PK][FK_MM_T2B][Information from the leaf]
[MM_T2B]
[PK][t_Branches][t_twigs]
[t_twigs]
[PK][Information about the twig]
[t_branches]
[PK][information about the branch]
When I tried to do the simple External>XML-Import my poor database had some 185 tables based on the nodes in the tree... very sad indeed... and there were no relationships to link the data in one table to the next.
No, I do not know where the XML came from.
This isn't an urgent as right now I'm manipulating the data by hand in Excel - but it's painful to do.
HOWEVER, if I open the file in excel it will place the data in the columns by level, etc...
So a group label in Col(A) spans the rows under that group etc... so I know the XML parser can skim the data. I'm almost to the point of instancing Excel, opening the XML in Excel and then walking the rows! However, I know there is an elegant way of doing this if I can just figure out how to solve tacking the recursion...
This is a Very Simplified version of the XML I'm working with and unfortunately the information is confidential.
so when I parse the file I'd like to distribute the information so that:
(Yes I thought about a pedigree type self linking within the [t_branches] and that may be how I end up merging the data; however, it doesn't help with tracking the parent to the child or subchild.
I'd post my VBA; however, it's very dirty right now dozens of Commented out lines of code and notations.
This is my recursion call:
zRecursion As Long - it's passed into the sub, incremented by one within the recursion scope
zSpiderGroupLev el as long - testing the <tag> to see if it's a group and if so then zSpiderGroupLev el = zRecursion
This is my print line to the text file:
I found a few example files to work with so attached are the results. These have really nothing to do with the actual XML data - just fodder for the recursion code while I develop the parser.
SiteXML.XML.txt <remove the .txt>
xmlParse.txt is the output file.
(the periods are added String(zRecursi on, ".") ) the end of file is "<*>" just tracking for me so that I know that we actually finished parsing the big file.
Loading the XML isn't an issue, I have working code for that, it's determining the level of recursion as I traverse the tree, branches, twigs, leaves. What I need to do is relate back the Leaves to the Twigs to Branches
(yes, I know: Nodes, Child Nodes, Subchild nodes, etc...)
Tables I'm looking at (simplified)
[t_leaves]
[PK][FK_MM_T2B][Information from the leaf]
[MM_T2B]
[PK][t_Branches][t_twigs]
[t_twigs]
[PK][Information about the twig]
[t_branches]
[PK][information about the branch]
When I tried to do the simple External>XML-Import my poor database had some 185 tables based on the nodes in the tree... very sad indeed... and there were no relationships to link the data in one table to the next.
No, I do not know where the XML came from.
This isn't an urgent as right now I'm manipulating the data by hand in Excel - but it's painful to do.
HOWEVER, if I open the file in excel it will place the data in the columns by level, etc...
So a group label in Col(A) spans the rows under that group etc... so I know the XML parser can skim the data. I'm almost to the point of instancing Excel, opening the XML in Excel and then walking the rows! However, I know there is an elegant way of doing this if I can just figure out how to solve tacking the recursion...
This is a Very Simplified version of the XML I'm working with and unfortunately the information is confidential.
Code:
'AIR CODE example xml
<Root>
<Group>
<UUID>1234<UUID />
<Name>GroupName<Name />
<!-- Blah Blah Blah ->
<Group>
<UUID>7890<UUID />
<Name>CatagoryName<Name />
<!-- Blah Blah Blah ->
<Entry>
<UUID>ABCD<UUID />
<ItemID>InternalIdOfItem<ItemID />
<ItemName>InternalNameOfItem<ItemName />
<!-- Blah Blah Blah ->
<Entry />
<Group />
<Group>
<!-- Here we have another Root\Group\child that follows the first child, different UUID etc... ->
<Group />
<Group />
<Root />
Code:
[t_leaves] [AutoNum_PK][1][ABCD][InternalIdOfItem][InternalNameOfItem] [AutoNum_PK][2][EFGH][InternalIdOfItem2][InternalNameOfItem2]
Code:
[MM_T2B] [1][1][20] [2][2][1] [3][15][null] [...]
Code:
[t_Twigs] [AutoNum_PK=1][7890][CatagoryName] [AutoNum_PK=2][A123][CatagoryName2]
Code:
[t_Branches] [AutoNumber_PK=1][0001][GroupName] [...] [AutoNumber_PK=20][1234][GroupName20]
I'd post my VBA; however, it's very dirty right now dozens of Commented out lines of code and notations.
This is my recursion call:
Code:
Call SpiderChildren(zSpider.childNodes, zRecursion, zSpiderGroupLevel)
zSpiderGroupLev el as long - testing the <tag> to see if it's a group and if so then zSpiderGroupLev el = zRecursion
This is my print line to the text file:
Code:
If PrintSpider Then _
Print #zFreeFile, String(zRecursion, ".") & _
" (" & " ParentNode: " & _
zSpider.ParentNode.basename & _
") (Spider: " & zSpider.basename & _
")(text: " & zSpider.Text & ")"
SiteXML.XML.txt <remove the .txt>
xmlParse.txt is the output file.
(the periods are added String(zRecursi on, ".") ) the end of file is "<*>" just tracking for me so that I know that we actually finished parsing the big file.
Comment