TinyXMLResource         Use TinyXML documents via Ogres resource system

Author:' xadhoom'

Discussion: Ogre Forum

The following class shows an example implementation for TinyXML documents via Ogres resource system (current version: 1.6.1 Shoggoth).

Its subclasses allow to open {LEX()}XML{LEX} files (with TinyXML) like you would do with .mesh files. You only have to call create and load as described and you will get a resource which contains the actual XML data of the file. This is useful for everything where you describe things in XML ...

  • TinyXMLResourceManager - The Ogre ResourceManager which creates new TinyXML resources
  • TinyXMLResource - The actual TinyXML document resource which supplies access to the TinyXMLDocument node

The source code can be found here.

Local copy here:

 Plugin disabled

Plugin attach cannot be executed.

To use the code you have to add the additional TinyXML dependencies. If you encounter problems you may have to
adapt the Header files. You can then use it like this:

// create our ResourceManager
OGRE_NEW TinyXMLResourceManager();

// create a new resource for our xml file 'MyFile.xml'
TinyXMLPtr myXMLFile = TinyXMLResourceManager::getSingleton().create("MyFile.xml", "MyResourceGroup");

// actually load our xml file

// if there was no loading error we can now retrieve the TiniYML node below
   LogManager::getSingletonPtr()->logMessage("An error occured in file " + xml->getName() + 
                                             " : " + String(xml->getErrorDesc()));
   TiXmlNode* node = xml->getXMLData();
   // perform operations on the xml structure

The class supports cloning:

TinyXMLPtr myXMLFile2 = myXMLFile->clone("myXMLFile2Name");

And the creation of manual XML resources.

// create a manual xml resource (normally you should add a ManualResourceLoader in case of a reload)   
TinyXMLPtr myXMLFile3 = 
   TinyXMLResourceManager::getSingleton().createManual("myXMLFile3Name", "MyGroup");

// retrieve the xml root node
TiXmlNode* node = xml->getXMLData();

// add attributes and elements to node as you like...