comparison dep/pugixml/docs/samples/save_declaration.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 <iostream>
4
5 int main()
6 {
7 // tag::code[]
8 // get a test document
9 pugi::xml_document doc;
10 doc.load_string("<foo bar='baz'><call>hey</call></foo>");
11
12 // add a custom declaration node
13 pugi::xml_node decl = doc.prepend_child(pugi::node_declaration);
14 decl.append_attribute("version") = "1.0";
15 decl.append_attribute("encoding") = "UTF-8";
16 decl.append_attribute("standalone") = "no";
17
18 // <?xml version="1.0" encoding="UTF-8" standalone="no"?>
19 // <foo bar="baz">
20 // <call>hey</call>
21 // </foo>
22 doc.save(std::cout);
23 std::cout << std::endl;
24 // end::code[]
25 }
26
27 // vim:et