若该文为原创文章,转载请注明原文出处
本文章博客地址:https://blog.csdn.net/qq21497936/article/details/111828450
长期持续带来更多项目与技术分享,咨询请加QQ:2149793六、微信:yangsir198808
红胖子(红模仿)的博文大全:开发技术集合(包含Qt实用技术、树莓派、三维、OpenCV、OpenGL、ffmpeg、OSG、单片机、软硬结合等等)持续更新中…(点击传送门)html
Qt开发Xml相关技术,使用到tinyxml2库。git
TinyXML是一个简单的、小的C++的XML解析器,能够集成到其余程序中。它是ROS的标准XML解析器。
最新的已是TinyXML2版本了。
github下载地址:https://github.com/leethomason/tinyxml2
CSDN下载地址:https://download.csdn.net/download/qq21497936/13944558
QQ群:1047134658(点击“文件”搜索“tinyxml2”,群内与博文同步更新)github
直接强上,先修改C编译器的
而后修改CXX编译器的微信
void TinyXmlManager::testEnv() { // 测试建立一个简单html文件 tinyxml2::XMLDocument doc; // 添加第一行 doc.Parse("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); // 添加第一个节点 // 添加第一个节点中的属性 <ofd:OFD xmlns:ofd="http://www.ofdspec.org" DocType="OFD" Version="1.0"> tinyxml2::XMLElement * pXmlElement; pXmlElement = doc.NewElement("ofd:OFD"); pXmlElement->SetAttribute("xmlns:ofd", "http://www.ofdspec.org"); pXmlElement->SetAttribute("DocType", "OFD"); pXmlElement->SetAttribute("Version", "1.0"); // 子节点 <ofd:DocBody> tinyxml2::XMLElement * pXmlElement2; pXmlElement2 = doc.NewElement("ofd:DocBody"); pXmlElement2->SetAttribute("Author", "红模仿"); pXmlElement2->SetAttribute("QQ", 21497936); pXmlElement2->SetAttribute("Blog", "https://blog.csdn.net/qq21497936"); pXmlElement->InsertEndChild(pXmlElement2); doc.InsertEndChild(pXmlElement); // 保存 doc.SaveFile("1.xml"); }
对应工程模板:tinyXmlDemo_v1.0.0_基础工程_运行环境测试.rar模块化
若该文为原创文章,转载请注明原文出处
本文章博客地址:https://blog.csdn.net/qq21497936/article/details/111828450测试