source: icGREP/icgrep-devel/icgrep/combine/pugixml/docs/samples/traverse_walker.cpp @ 5516

Last change on this file since 5516 was 5516, checked in by faldebey, 21 months ago

added combinatorial testing tool

File size: 740 bytes
Line 
1#include "pugixml.hpp"
2
3#include <iostream>
4
5const char* node_types[] =
6{
7    "null", "document", "element", "pcdata", "cdata", "comment", "pi", "declaration"
8};
9
10// tag::impl[]
11struct simple_walker: pugi::xml_tree_walker
12{
13    virtual bool for_each(pugi::xml_node& node)
14    {
15        for (int i = 0; i < depth(); ++i) std::cout << "  "; // indentation
16
17        std::cout << node_types[node.type()] << ": name='" << node.name() << "', value='" << node.value() << "'\n";
18
19        return true; // continue traversal
20    }
21};
22// end::impl[]
23
24int main()
25{
26    pugi::xml_document doc;
27    if (!doc.load_file("tree.xml")) return -1;
28
29    // tag::traverse[]
30    simple_walker walker;
31    doc.traverse(walker);
32    // end::traverse[]
33}
34
35// vim:et
Note: See TracBrowser for help on using the repository browser.