I am trying to parse a large XML File (1.8 GB) using RapidXML in C++. While I can get the children of any specific node using the following method :
for(xml_node<> *child = node->first_node(); child; child = child->next_sibling()) {
...
}
I cant figure out how to parse it Depth first wise. RapidXML does not provide any inbuilt iterators for the same. Is there any other performance intensive library for large xml processing (in DOM, not SAX)?
You're confusing the parsing of the XML with the traversal of the content.
RapidXML parses the XML in a single, linear pass, constructing the object tree as it goes. You can then traverse the tree in any way that you want.
A depth-first search is typically a recursive procedure, but within your search you WILL be iterating over all the siblings of each node, using the code that you've shown. The difference is what you do with each node as you iterate over it.
void processNode(xml_node<> node)
{
for(xml_node<> *child = node->first_node(); child; child = child->next_sibling())
{
processNode(child);
... and do more stuff here...
}
}