Thread: Good XML Parser

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    64

    Good XML Parser

    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

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Not sure if it is up to the task but I use tinyxml and it works really well. Perhaps it isn't the best but it is free and it is easy to use.

    Another option might be xerces xml but I forget where to get it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with this xml tree example
    By kzar in forum C Programming
    Replies: 1
    Last Post: 11-22-2004, 11:23 AM
  2. xml parser: recommendations?
    By captain-cat in forum C Programming
    Replies: 1
    Last Post: 07-26-2004, 09:54 AM
  3. Problem with Apache XML C++ Parser library
    By gandalf_bar in forum C++ Programming
    Replies: 2
    Last Post: 07-21-2004, 09:42 AM
  4. XML Navigation
    By Khelder in forum C# Programming
    Replies: 2
    Last Post: 05-26-2004, 03:19 PM
  5. Anyone good at XML Schema?
    By Waldo2k2 in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 05-30-2002, 10:05 AM