#include <sstream>
xml_document doc;
// 设置XML的版本和编码
xml_node decl = doc.prepend_child(node_declaration);
// 设置XML版本
decl.append_attribute("version") = "1.0";
// 设置XML编码
decl.append_attribute("encoding") = "UTF-8";
//创建根节点
xml_node root = doc.append_child("root");
//存到QString中
std::stringstream os;
doc.save(os, "\t");
m_strInfo = QString::fromUtf8(os.str().c_str());//使用fromUtf8存到QString中不会乱码
doc.save_file("save.xml");//保存为xml文件
pugixml保存内容为string
最新推荐文章于 2024-06-18 23:13:36 发布