Version 1 (modified by landauf, 13 years ago) (diff) |
---|
XML-Writer
Under construction
Library
Suggestion: Simple C++ class for XML writing from Oboltus.
Using this class is very very simple, it's all based on the stream operator <<. Here's an example:
ofstream f("sample.xml"); XmlStream xml(f); xml << prolog() // write XML file declaration << tag("sample-tag") // root tag << tag("some-tag") // child tag << attr("int-attribute") << 123 << attr("double-attribute") << 456.789 << chardata() << "This is the text" << endtag() // close current tag << tag("empty-self-closed-tag") // sibling of <some-tag> << endtag() << tag() << "computed-name-tag" << attr("text-attr") << "a bit of text" << endtag() << tag("deep-tag") // deep enclosing << tag("sub-tag-2") << tag("sub-tag-3") << endtag("deep-tag"); // close all tags up to specified // you don't worry about closing all open tags!
Result:
<?xml version="1.0"?> <sample-tag> <some-tag int-attribute="123" double-attribute="456.789">This is the text </some-tag> <empty-self-closed-tag/> <computed-name-tag text-attr="a bit of text"/> <deep-tag> <sub-tag-2> <sub-tag-3/> </sub-tag-2> </deep-tag> </sample-tag>
The layout isn't optimal yet, but I'll try to fix that.
Misc
See archive/XML-Loader? for an XML-Reader description