Hello, I am John Montefusco. I have been working on a programming project in my college. The basic goal is to create a program to take various metrics involved in an XML file (my professors doctoral research :P) I have been trying to use tiny to do the parsing, so we can just traverse the tree and essentially count stuff. The first hurdle is just making a basic program that will count the occurences of element tags. However i've been having a little trouble :P I cant seem to get a function that will traverse the entire tree to work, Should i be using the handlers or just direcly using node/element pointers. I'd greatly appreciate any help, I figure I must be doing something stupid as it would seem tree traversal would be the most rudimentary thing you want to do with a tree :P
I would appreciate any help :)
- John Montefusco
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
IterateChildren takes the previous child as input and finds the next one. If the previous child is null, it returns the first. IterateChildren will return null when done.
"IterateChildren" is probably the easiest. Search for "IterateChildren" in xmltest.cpp for an example.
lee
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
thnx, i just needed to sleep on it and look at it with a more clear head ^_^ i was confused as to what an element or node actually meant but now i have a recursive solution to traverse the tree, thanks :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello, I am John Montefusco. I have been working on a programming project in my college. The basic goal is to create a program to take various metrics involved in an XML file (my professors doctoral research :P) I have been trying to use tiny to do the parsing, so we can just traverse the tree and essentially count stuff. The first hurdle is just making a basic program that will count the occurences of element tags. However i've been having a little trouble :P I cant seem to get a function that will traverse the entire tree to work, Should i be using the handlers or just direcly using node/element pointers. I'd greatly appreciate any help, I figure I must be doing something stupid as it would seem tree traversal would be the most rudimentary thing you want to do with a tree :P
I would appreciate any help :)
- John Montefusco
From the tinyxml header:
/** An alternate way to walk the children of a node.
One way to iterate over nodes is:
for( child = parent->FirstChild(); child; child = child->NextSibling() )
IterateChildren does the same thing with the syntax:
child = 0;
while( child = parent->IterateChildren( child ) )
IterateChildren takes the previous child as input and finds the next one. If the previous child is null, it returns the first. IterateChildren will return null when done.
"IterateChildren" is probably the easiest. Search for "IterateChildren" in xmltest.cpp for an example.
lee
thnx, i just needed to sleep on it and look at it with a more clear head ^_^ i was confused as to what an element or node actually meant but now i have a recursive solution to traverse the tree, thanks :)