ANNOUNCE: XMLIO ver 0.3 - nestable C++ XML parser/writer

Paul Miller stele at
Tue Dec 21 01:40:50 GMT 1999

This is my simple nestable, streaming, XML parser for C++ application
data, now layered over expat (thanks to all who provided prods in the
right direction). Version 0.3 also adds chained element handlers and
support for parsing lists.

I've decided to release this under the MIT(X11) license, which I feel is
the least restrictive of the popular licenses. How this will conflict
with James Clark's expat license, I don't know yet (I'm not a lawyer nor
do I try to play one on the internet, and I didn't want to bother trying
to interpret the Mozilla license). If there is a problem, someone please
let me know!

UNICODE isn't support yet, and I'm sure there are still bugs, but I've
tried this on data-files with thousands of elements and it seems fairly
quick. I still have some optimizations to do in the memory department,
to avoid unnecessary allocation/deallocation overhead.

An ANSI C++ compiler with namespaces, exceptions, and the standard
library is required. A vanilla "C" version of this API could be built,
if there is desire.

Please check the sample object implementation (sample.cpp and sample.h)
in the distribution for an example of how this API should be used.

A quick example of how the list-parsing feature mentioned above works.
Lets say I have this class:

class Date
	enum Day
		Sunday, Monday, Tuesday, 
		Wednesday, Thursday, Friday, Saturday, Days

	static const char *labels[Days] = 
	{ "Sunday", "Monday", "Tuesday", 
	"Wednesday", "Thursday", "Friday", "Saturday" };

	void Write(XML::Output &out) const;
	void Read(XML::Parser &in);

	int m_day;

void Date::Write(XML::Output &out) const
	// write out an element with the day as text
	out.WriteElement("Day", labels[m_day]);

void Date::Read(XML::Parser &in)
	// set up a handler for the date as a list
	XML::Handler handlers[] = {
		XML::Handler("Day", &m_day, labels, Days),
	in.Parse(handlers, this);

Note the handler for the "Day" element above takes a pointer to an int
and an array of character strings and a total. When the "Day" element is
encountered it will automatically compare the element data with the
provided list, and write the index of the day found in the m_day
variable. It will throw an exception if an invalid Day is provided.

Paul Miller - stele at

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at
Archived as: and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo at the following message;
unsubscribe xml-dev
To subscribe to the digests, mailto:majordomo at the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at

More information about the Xml-dev mailing list