Tiny XML
Copyright (c) 2009 by Brian O. Bush
Small, fast, memory efficient, embeddable SAX-parser for XML in C.
What is it?
Yet another XML library? Didn't you already write one? Yes, I did, see picoxml
The origins of tinyxml come from my development on the Nintendo DS and basically inverted pico XML to be a SAX-like parser and some other improvements (and fixes).
Features
- Plain ANSI C, no external library dependencies
- Tiny and embeddable (less than 400 lines of C code)
- Handles start/end tags, text, attribute names and values
- Handles UTF-8 only (ASCII is a proper subset of UTF-8, thus supported)
Caveats
- Like SAX1 with regards to features; SAX1 omits Comments, Lexical Information (CDATA sections, entity references, etc.), DTD declarations, Validation, Namespaces.
- Non-validating, however, you can do your own validation, e.g., expect specific tags and fail if not found at the application level.
Building
Simply unpack the tarball and run the scons (SConstruct) in the untarred directory:
$ scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
tarball_builder_fn(["tinyxml-20090813.tar.gz"], ["tinyxml.c", "tinyxml_test.c", "tinyxml_ex.c", "tinyxml.h", "SConstruct", "tarball.py", "sample.xml"])
gcc -o tinyxml.o -c -Wall -Werror -pedantic -g -O2 -std=c99 tinyxml.c
gcc -o tinyxml_test.o -c -Wall -Werror -pedantic -g -O2 -std=c99 tinyxml_test.c
gcc -o tinyxml_test tinyxml.o tinyxml_test.o
scons: done building targets.
You should now have two test applications, tinyxml_test and tinyxml_ex. See source for those examples for how to employ the tinyxml API for your application.
$ ./tinyxml_test sample.xml
[start tag] deck
[start tag] card
[attr name] id
[attr val] 1
[start tag] q
[text] one
[end tag] /q
[start tag] a
[text] δΈ€
...
Download
Release 0.1 - Initial public release, 13-Aug-2009.
License
GNU Lesser General Public License (LGPL)
Contact
I would be interested in an applications using tinyxml, bug reports or patches.
Thanks,
Brian O. Bush,
brianobush@gmail.com
13-Aug-2009