zoukankan      html  css  js  c++  java
  • 用tinyxml2读写xml文件_C++实现

    下载源代码

    开源代码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 );
  • 相关阅读:
    python之字典操作
    python之元组操作
    初始超算
    后缀自动机
    博弈
    曼哈顿最小生成树
    莫队算法
    主席树
    [HNOI2014]世界树
    [SDOI2011]消耗战
  • 原文地址:https://www.cnblogs.com/xbit/p/9046094.html
Copyright © 2011-2022 走看看