aboutsummaryrefslogtreecommitdiff
path: root/example.cpp
diff options
context:
space:
mode:
authorOskari Timperi <oskari.timperi@iki.fi>2011-06-01 11:23:15 +0300
committerOskari Timperi <oskari.timperi@iki.fi>2011-06-01 11:23:15 +0300
commit282f3e36efb9b95e91d2c56568ad8019bcde6e3f (patch)
tree8636d6fcaf9441eccced50024d3adc6e44afd9e1 /example.cpp
parenta8091a9031f26dcdab1e14a55fd46d0603c225de (diff)
downloadsxml-282f3e36efb9b95e91d2c56568ad8019bcde6e3f.tar.gz
sxml-282f3e36efb9b95e91d2c56568ad8019bcde6e3f.zip
Add some comments to the example
Diffstat (limited to 'example.cpp')
-rw-r--r--example.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/example.cpp b/example.cpp
index 8346749..9c8c74b 100644
--- a/example.cpp
+++ b/example.cpp
@@ -31,13 +31,19 @@ using sxml::element;
using sxml::comment;
int main()
{
+ // make a new element
element *root = new element("root");
+ // add "node" with attribute "id" to "root" element
root->add_element("node")->set_attr("id", 0);
+ // add a comment after the node
root->add_comment("yay, a comment");
+
+ // add another node with different id attribute value
root->add_element("node")->set_attr("id", 1);
+ // methods returning pointers comes handy sometimes.
element *node = root->add_element("node")->set_attr("id", 3.1);
node = node->add_element("subnode");
node->add_element("subsubnode")->add_comment(
@@ -46,8 +52,10 @@ int main()
node = root->add_element("node")->set_attr("id", 6);
node = node->add_element("subnode")->set_attr("id", 66);
+ // this should move the "subnode" from "node" to "root"
root->add_child(node);
+ // print the whole tree to stdout.
std::cout << root->to_string(true) << std::endl;
return 0;