开源代码github地址: https://github.com/leethomason/tinyxml2

添加工程文件

将源代码目录中 tinyxml2.htinyxml2.cpp 文件拷贝到工程目录下,并加入到工程中。

添加头文件和命名空间

#include "tinyxml2/tinyxml2.h"
using namespace tinyxml2;

 

写入代码片段: attribute name可以用任意名字,并且同一级nodes可以用相同的element name

tinyxml2::XMLElement* cityElement = doc.NewElement( "City" );
cityElement->SetAttribute( "name_xyz", "ChangSha" ); // 设置元素属性
root->InsertEndChild( cityElement );

tinyxml2::XMLElement
* cityElement = doc.NewElement( "City" ); cityElement->SetAttribute( "name_xyz", "ChangSha" ); // 设置元素属性 root->InsertEndChild( cityElement );

 

相关文章:

  • 2021-08-05
  • 2021-06-06
  • 2021-08-30
  • 2021-11-25
  • 2022-12-23
  • 2021-05-02
猜你喜欢
  • 2022-02-19
  • 2021-10-10
  • 2021-11-29
  • 2021-06-26
  • 2022-01-24
  • 2021-06-14
  • 2022-12-23
相关资源
相似解决方案