An open-source XML generation library from Tim Bray - will have a need for this a bit later.
Small dissappointment - it is written in “C” rather than “C++”. I suspect a carefully written C++ class could give better performance (we are talking about mashing a lot of bytes around).
Big upside - this looks like very clean code. Hey - a guy that uses opaque pointers in “C” probably has a clue. Also this is not his first time through a similar exercise, so you can expect the ideas expressed in the code to be more clearly thought out.