I'm creating a tool for my 3D engine right now that converts Collada model format to my own format.
So far, I'm on the process on reading the said format which needs a xml parser for c++ using rapidxml.
Does all parser loads like let say. node->first_child() or node->next_sibling(). I mean.. sequentially? I guess that's the right word. Here take a look at my code:
Code:
for (node = node->first_node(); node; node = node->next_sibling())
{
cout << "Name of node: " << node->name() << endl;
if( !strcmp(node->name(), "asset") )
{
for (xml_node<> *assetnode = node->first_node(); assetnode; assetnode = assetnode->next_sibling())
{
if( !strcmp(assetnode->name(), "contributor") )
{
for (xml_node<> *contributornode = assetnode->first_node(); contributornode; contributornode = contributornode->first_node())
{
if( !strcmp(contributornode->name(), "author") )
{
cout << contributornode->name() << " = '" << contributornode->value() << "'" << endl;
}
}
}
else if( !strcmp(assetnode->name(), "created") )
{
cout << assetnode->name() << " = '" << assetnode->value() << "'" << endl;
}
else if( !strcmp(node->name(), "modified") )
{
cout << assetnode->name() << " = '" << assetnode->value() << "'" << endl;
}
}
}
else if( !strcmp(node->name(), "library_effects") )
{
//Do something
node = node->next_sibling();
}
}
So with that question on my mind, I look at the assimp source code and found out that they use irrXml which read a xml in different way. Now, they use something like mReader->read() (this one just read and don't check any siblings I guess. or I mean without passing a node to another node to another like the one in bold above.) then check something like mReader->getName() == "Aha!" ...
or maybe I just do it wrong?
What bothers me right now is that I think my codes are really messy. So, can anyone here suggest a good fast xml parser that loads maybe 50mb ~ 500mb+ xml fast.
Thank you
Sarah