Mercurial > minori
comparison dep/pugixml/docs/samples/traverse_base.cpp @ 55:d10b6c6b432e
add xml lib, we will need to use it eventually
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Tue, 26 Sep 2023 12:37:08 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
54:466ac9870df9 | 55:d10b6c6b432e |
---|---|
1 #include "pugixml.hpp" | |
2 | |
3 #include <string.h> | |
4 #include <iostream> | |
5 | |
6 int main() | |
7 { | |
8 pugi::xml_document doc; | |
9 if (!doc.load_file("xgconsole.xml")) return -1; | |
10 | |
11 pugi::xml_node tools = doc.child("Profile").child("Tools"); | |
12 | |
13 // tag::basic[] | |
14 for (pugi::xml_node tool = tools.first_child(); tool; tool = tool.next_sibling()) | |
15 { | |
16 std::cout << "Tool:"; | |
17 | |
18 for (pugi::xml_attribute attr = tool.first_attribute(); attr; attr = attr.next_attribute()) | |
19 { | |
20 std::cout << " " << attr.name() << "=" << attr.value(); | |
21 } | |
22 | |
23 std::cout << std::endl; | |
24 } | |
25 // end::basic[] | |
26 | |
27 std::cout << std::endl; | |
28 | |
29 // tag::data[] | |
30 for (pugi::xml_node tool = tools.child("Tool"); tool; tool = tool.next_sibling("Tool")) | |
31 { | |
32 std::cout << "Tool " << tool.attribute("Filename").value(); | |
33 std::cout << ": AllowRemote " << tool.attribute("AllowRemote").as_bool(); | |
34 std::cout << ", Timeout " << tool.attribute("Timeout").as_int(); | |
35 std::cout << ", Description '" << tool.child_value("Description") << "'\n"; | |
36 } | |
37 // end::data[] | |
38 | |
39 std::cout << std::endl; | |
40 | |
41 // tag::contents[] | |
42 std::cout << "Tool for *.dae generation: " << tools.find_child_by_attribute("Tool", "OutputFileMasks", "*.dae").attribute("Filename").value() << "\n"; | |
43 | |
44 for (pugi::xml_node tool = tools.child("Tool"); tool; tool = tool.next_sibling("Tool")) | |
45 { | |
46 std::cout << "Tool " << tool.attribute("Filename").value() << "\n"; | |
47 } | |
48 // end::contents[] | |
49 } | |
50 | |
51 // vim:et |