Skip to content

AeonXML

AeonXML is yet another C++ Wrapper for the eXpat-library aiming to be lightweight, yet before all as standalone as possible. It ships with the eXpat library (2.0.1) pre-configured for every platform, so it doesn’t depend on any external library except the STL. This makes it very easy to integrate AeonXML into an existing project: One has basically just to copy the header and source files into (a seperate folder of) the project, include the headers and start using the library.

Features

  • Since AeonXML is based upon eXpat, it comes with its advantages, of course:
    • Stream-oriented parsing, thus parsing can be paused and resumed
    • Event-driven Parsing (SAX) using callback-functions
    • Very fast at low memory consumption (No expensive DOM tree population)
    • Validating parser
  • AeonXML specific features:
    • Wraps the eXpat C-API into a convenient object-oriented C++ API
    • Provides an Interface to implement your own Handlers
    • Provides Adapter Classes to save you from implementing everything over and over again
    • Comes with a pre-made, abstract Handler implementation* using STL strings and vectors to easily access XML elements and attributes
    • Tries to adapt C++ standards, offering a forward declaration header, RAII and a thread-safety.

(* It is optimized as far as STL Strings and vectors are optimizable, the necessary conversion comes at the cost of some speed of course.)

Documentation

The documentation can be found online at http://www.gatewayheaven.com/docs/AeonXML/ or within the downloadable package.

Example Usage

AeonXML comes with an example program, which demonstrates how to use the premade SAXHandler class:

#include <SAXHandler.h>
#include <XMLString.h>
#include <XMLAttributes.h>

class MySAXHandler : public SAXHandler {
public:
    void startElement(const XMLString& name, const XMLAttributes& attributes) {
        if(name == "item") {
           std::cout << attributes.get("id");
        }
    }
    // The other callback functions are used similarly
    // ...
};

Creating and using the parser is just as simple:

SAXParser parser(new MySAXHandler());

try {
    parser.parse("file.xml");
} catch (SAXParserException& e) {
    // Handle exception
}

Download

The latest source code can be found over at GitHub: http://github.com/Xography/AeonXML, just press the “Download Source Button” (or click here for .zip or .tar.gz