ambiera home ambiera home


irrXML is a simple and fast open source xml parser for C++. Why another xml parser? The strenghts of irrXML are its speed and its simplicity. It ideally fits into realtime projects which need to read xml data without overhead, like games. irrXML was originally written as part of the Irrlicht Engine but after it has become quite mature it now has become a separate project.


irrXML simply provides forward-only, read-only access to a stream of non validated XML data. Its current features are:

  • It it fast as lighting and has very low memory usage. It was developed with the intention of being used in 3D games, as it already has been.
  • It's open source, with an OSI certified license (zlib)
  • irrXML is very small: It only consists of 60 KB of code and can be added easily to your existing project.
  • Of course, it is platform independent and works with lots of compilers.
  • It is able to parse ASCII, UTF-8, UTF-16 and UTF-32 text files, both in little and big endian format.
  • Independent of the input file format, the parser can return all strings in ASCII, UTF-8, UTF-16 and UTF-32 format.
  • With its optional file access abstraction it has the advantage of reading easily not only from files but from any type of data (memory, network, ...). For example when used with the Irrlicht Engine, it directly reads from compressed .zip files.
  • Just like the Irrlicht Engine for which it was originally created, it is extremely easy to use.
  • It has no external dependencies, it does not even need the STL.


The following code demonstrates the basic usage of irrXML. A simple xml file like this is parsed:

<?xml version="1.0"?>
<!-- This is a config file for the mesh viewer -->
<model file="dwarf.dea" />
<messageText caption="Irrlicht Engine Mesh Viewer">
Welcome to the Mesh Viewer of the &quot;Irrlicht Engine&quot;.

The code for parsing this file would look like this:

#include <irrXML.h>
using namespace irr; // irrXML is located 
using namespace io;  // in the namespace irr::io

#include <string> // we use STL strings to store data
// in this example void main() { // create the reader using one of the factory functions IrrXMLReader* xml = createIrrXMLReader("config.xml"); // strings for storing the data we want to get out of the file std::string modelFile; std::string messageText; std::string caption; // parse the file until end reached while(xml && xml->read()) { switch(xml->getNodeType()) { case EXN_TEXT: // in this xml file, the only text which
// occurs is the messageText
messageText = xml->getNodeData(); break; case EXN_ELEMENT: if (!strcmp("model", xml->getNodeName())) modelFile = xml->getAttributeValue("file"); else if (!strcmp("messageText", xml->getNodeName())) caption = xml->getAttributeValue("caption"); break; } } // delete the xml parser after usage delete xml; }