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

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

added combinatorial testing tool

File size: 1.1 KB
Line 
1#include "pugixml.hpp"
2
3#include <iostream>
4
5int main()
6{
7    pugi::xml_document doc;
8
9    // get a test document
10    doc.load_string("<project><name>test</name><version>1.1</version><public>yes</public></project>");
11
12    pugi::xml_node project = doc.child("project");
13
14    // tag::access[]
15    std::cout << "Project name: " << project.child("name").text().get() << std::endl;
16    std::cout << "Project version: " << project.child("version").text().as_double() << std::endl;
17    std::cout << "Project visibility: " << (project.child("public").text().as_bool(/* def= */ true) ? "public" : "private") << std::endl;
18    std::cout << "Project description: " << project.child("description").text().get() << std::endl;
19    // end::access[]
20
21    std::cout << std::endl;
22
23    // tag::modify[]
24    // change project version
25    project.child("version").text() = 1.2;
26
27    // add description element and set the contents
28    // note that we do not have to explicitly add the node_pcdata child
29    project.append_child("description").text().set("a test project");
30    // end::modify[]
31
32    doc.save(std::cout);
33}
34
35// vim:et
Note: See TracBrowser for help on using the repository browser.