diff options
| author | Oskari Timperi <oskari.timperi@iki.fi> | 2011-06-01 10:52:04 +0300 |
|---|---|---|
| committer | Oskari Timperi <oskari.timperi@iki.fi> | 2011-06-01 10:52:04 +0300 |
| commit | a71564984253ade92fc4d3c9bf185807efc570bf (patch) | |
| tree | 93e267348605dda8f32262a4d912c33e7720c074 /example.cpp | |
| parent | 5fb5bb1c7cc0ce266f60ab272915a48770d1443f (diff) | |
| download | sxml-a71564984253ade92fc4d3c9bf185807efc570bf.tar.gz sxml-a71564984253ade92fc4d3c9bf185807efc570bf.zip | |
New classes: node and comment.
Move functionality from element to node and derive element
from node. This allows nodes to contain different types of
nodes, e.g. comments mixed with normal elements.
Diffstat (limited to 'example.cpp')
| -rw-r--r-- | example.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/example.cpp b/example.cpp index fa1574c..bbc3bbd 100644 --- a/example.cpp +++ b/example.cpp @@ -22,27 +22,29 @@ * 3. This notice may not be removed or altered from any source * distribution. */ - + #include <iostream> #include "sxml.h" using sxml::element; - +using sxml::comment; int main() { - element root("summary"); - - root.add_child(element("foo", "lorem ipsum")) - - .add_child(element("bar") - .add_child(element("foobar", "bazinga!")) - .set_attr("id", "1337")) - - .add_child(element("mother").add_child(element("child"))); - - std::cout << root.to_string(true) << std::endl; - + element *root = new element("root"); + + root->add_element("node")->set_attr("id", 0); + + root->add_child(new comment("yay, a comment!")); + root->add_element("node")->set_attr("id", 1); + + element *node = root->add_element("node")->set_attr("id", 3.1); + node = node->add_element("subnode") + node->add_element("subsubnode")->add_child( + new comment("i am in pretty deep waters here, man ..")); + + std::cout << root->to_string(true) << std::endl; + return 0; } |
