Menu

Home

Anthony Daniels

XML* or XMLStar
An STL based simple XML serialization and de-serialization engine.
Version 0.8.0
Anthony Daniels

This package is intended to provide the user with a simple to use XML serialization engine. I was originally going to call it XMLite but that name was already taken by Microsoft. The intent is to have a lightweight system. It handles basic XML elements, attributes, comments and processes. More complicated syntax is not supported. For example, it can read a Microsoft word generated xml file but it can’t save that text file back to XML for Microsoft to use. However for simple XML it works fine. It has also been used on some fairly large files for testing. XMLStar is LGPL Licensed.

1 Reading in XMLStar
This is done by creating a root node or top XMLElement and an XMLReader class
Std::string strXMLInput //xml string data inputed into this string first via assignment or streaming in.

XMLElementIndex objRootIndex;
XMLElement objTopNode;
XMLReader objReader;

//Loading an XML is done by this
/LoadXMLTree(XMLElement * ptrCurrTop,const std::string & strInput, XMLElementIndex & objCurrElementIndex)/

objReader.LoadXMLTree( &objTopNode,strXMLInput,objRootIndex);

The XML input string is then parsed by the reader and the full XML object tree is created with the objTopNode as the root. There are overloads for using string streams and file streams as well.

//XML SERIALIZATION AND DE-SERIALIZATION METHODS///////////
//!Expand the XML string value of the element
virtual int LoadXMLTree(XMLElement * ptrCurrTop, const std::string & strInput, XMLElementIndex & objCurrElementIndex);

virtual int LoadXMLTree(XMLElement * ptrCurrTop, std::istream & strStreamInput);

virtual int LoadXMLTree(XMLElement * ptrCurrTop, std::ifstream & strStreamInput);

2 Writing in XMLStar

Writing in XMLStar is similar to reading. The user takes their built XML tree and feeds the top element and the target output string into the XMLWriter.

Std::string strXMLOutput;
XMLElement objTopNode;
//build your xml tree before exporting to text

XMLWriter objWriter;

//loading an XML is done by this
/SaveXMLTree(XMLElement * ptrCurrTop, std::string & strOutput, bool blnWithFormatting);/

objWriter.SaveXMLTree(&objTopNode, strXMLOutput, true);

These are the various overloads for the Save function.

//XML SERIALIZATION AND DE-SERIALIZATION METHODS///////////
//!Save the entire XML Tree to desired string output
virtual int SaveXMLTree(XMLElement * ptrCurrTop, std::string & strOutput, bool blnWithFormatting);

virtual int SaveXMLTree(XMLElement * ptrCurrTop, std::ostream & strStreamOut, bool blnWithFormatting);

virtual int SaveXMLTree(XMLElement * ptrCurrTop, std::ofstream & strStreamOut, bool blnWithFormatting);