From 282f3e36efb9b95e91d2c56568ad8019bcde6e3f Mon Sep 17 00:00:00 2001 From: Oskari Timperi Date: Wed, 1 Jun 2011 11:23:15 +0300 Subject: Add some comments to the example --- example.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'example.cpp') 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; -- cgit v1.2.3