navi homePPSaboutscreenshotsdownloaddevelopmentforum

Version 1 (modified by landauf, 9 years ago) (diff)


Under construction


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!


<?xml version="1.0"?>
<some-tag int-attribute="123" double-attribute="456.789">This is the text
<computed-name-tag text-attr="a bit of text"/>

The layout isn't optimal yet, but I'll try to fix that.


See archive/XML-Loader? for an XML-Reader description