falcong / pugixml

Automatically exported from code.google.com/p/pugixml
0 stars 0 forks source link

encoding #97

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi 
Please how can I make my generated documment have encoding attributes like this.

<?xml version="1.0" encoding="iso-8859-1" ?>

Thanks

Original issue reported on code.google.com by n9ine.c...@gmail.com on 18 Mar 2011 at 10:30

GoogleCodeExporter commented 9 years ago
I find it my self, thanks 

pugi::xml_node decl = doc_writer.prepend_child(pugi::node_declaration);
decl.append_attribute("version").set_value("1.0");
decl.append_attribute("encoding").set_value("iso-8859-1");
doc_writer.append_child(pugi::node_declaration);

Original comment by n9ine.c...@gmail.com on 18 Mar 2011 at 10:47

GoogleCodeExporter commented 9 years ago
Yep, that's the way; note that the last line is redundant (it'll detect that 
there is already a declaration node and cancel the operation.

Original comment by arseny.k...@gmail.com on 18 Mar 2011 at 4:24