Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Initial Version and Version 1 of ~archive/XML-Writer


Ignore:
Timestamp:
Aug 22, 2011, 2:20:24 PM (13 years ago)
Author:
landauf
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • ~archive/XML-Writer

    v1 v1  
     1= XML-Writer =
     2
     3''Under construction''
     4
     5== Library ==
     6
     7Suggestion: [http://www.codeproject.com/vcpp/stl/simple_xmlwriter.asp Simple C++ class for XML writing] from Oboltus.
     8
     9Using this class is very very simple, it's all based on the stream operator <<. Here's an example:
     10
     11{{{
     12ofstream f("sample.xml");
     13XmlStream xml(f);
     14
     15xml << prolog() // write XML file declaration
     16  << tag("sample-tag") // root tag
     17
     18    << tag("some-tag") // child tag
     19      << attr("int-attribute") << 123
     20      << attr("double-attribute") << 456.789
     21      << chardata() << "This is the text"
     22    << endtag() // close current tag
     23
     24    << tag("empty-self-closed-tag") // sibling of <some-tag>
     25    << endtag()
     26
     27    << tag() << "computed-name-tag"
     28      << attr("text-attr") << "a bit of text"
     29    << endtag()
     30
     31    << tag("deep-tag") // deep enclosing
     32      << tag("sub-tag-2")
     33        << tag("sub-tag-3")
     34    << endtag("deep-tag"); // close all tags up to specified
     35
     36// you don't worry about closing all open tags!
     37}}}
     38
     39Result:
     40
     41{{{
     42<?xml version="1.0"?>
     43<sample-tag>
     44<some-tag int-attribute="123" double-attribute="456.789">This is the text
     45</some-tag>
     46<empty-self-closed-tag/>
     47<computed-name-tag text-attr="a bit of text"/>
     48<deep-tag>
     49<sub-tag-2>
     50<sub-tag-3/>
     51</sub-tag-2>
     52</deep-tag>
     53</sample-tag>
     54}}}
     55
     56The layout isn't optimal yet, but I'll try to fix that.
     57
     58= Misc =
     59See [wiki:archive/XML-Loader] for an XML-Reader description