Thanks for the reply.
1.) I checked out this tinyXML Library ogre is using. It has much more Classes and methods than the XML parser, but is also more complicated to use. It can both read and write XML Files. I tried to compile and run it on tardis, but didn't suceed yet, don't know if there's an error with solaris, or the stl, or the encoding or whatever. XML support in ogre is only used for this mesh importing thing. I didn't find any other XML stuff in the API or in the docs.
2.) I also tried this xmlparser I found in the first place, and after playing around with the makefile I was able to compile and run it. This parser is easy to use because it has only one class object which can do a lot of things. It's also possible to write XML files with it and it does not depend on any other libraries. It supports also some smart memory management to handle big files (wasn't yet able to test that, but the description on their page sounds good
) and it also has error handling if the file has incorrect XML. So this is my favorite library to use.
Example:
Input:
click
Code-Sample:
Code: Select all
XMLNode mNode=XMLNode::openFileHelper("campaign.xml","campaign");
const char* campaignName = mNode.getChildNode("name").getText();
const char* campaignIdentifier = mNode.getChildNode("identifier").getText();
const char* campaignDesc = mNode.getChildNode("description").getText();
cout << "Campaign: " << campaignName
<< ", Id: " << campaignIdentifier
<< ", Desc: " << campaignDesc << "\n";
XMLNode worldNode = mNode.getChildNode("worldlist");
XMLNode menuNode = worldNode.getChildNode("gamemenu");
const char* menuName = menuNode.getChildNode("name").getText();
cout << "Menu: "<<menuName
<<", containing "<<worldNode.nChildNode("SinglePlayerWorld")
<<" SinglePlayer items\n";
for (int x=0;x<worldNode.nChildNode("SinglePlayerWorld");x++)
{
XMLNode spgNode = worldNode.getChildNode("SinglePlayerWorld",x);
cout << "World: "<<spgNode.getChildNode("name").getText()
<< " ("<<spgNode.getChildNode("identifier").getText()
<< "), Path: "<<spgNode.getChildNode("path").getText()<<"\n";
}
Output:
Code: Select all
Campaign: default, Id: 0, Desc: The one and only default debug campaign
Menu: GameMenu, containing 8 SinglePlayer items
World: Cut Scene (1), Path: levels/sp_cutscene_intro.oxw
World: Space Station (2), Path: levels/sp_level_spacestation1.oxw
World: Space Station 1B (3), Path: levels/sp_level_spacestation1B.oxw
World: Vertical Scroller (4), Path: levels/vertical_scroller.oxw
World: Moonstation (5), Path: levels/sp_level_moonstation.oxw
World: Moonstation Hangar (6), Path: levels/sp_level_moonstation_hangar.oxw
World: Enemy Debug (7), Path: levels/debug_enemy.oxw
World: Adm Test (8), Path: levels/adm_test.oxw
For the XML-writing part we can either use this library or the library I described
here. This lib is also very simple to use, but the writing-support in xmlParser is more object orientated and also not too complicated, and the xml-output is better formated.
3.) I don't exactly understand what you mean by extending ogre; I would see the implementation of this whole loader directly in Orxonox, for examl
ple as a xmlImport class with inherited subclasses for level, campaign etc importing. All the objects it loads from a level file will then be added to a levelmanager (who's writing this one, or is it also part of this ticket?). My idea is to make a generic importer which can then be inherited when it's clear what data the game needs, but I'm a but unsure at the moment where to start with all this stuff...