美文网首页
tinyXml2 的基本用法

tinyXml2 的基本用法

作者: xuxiang | 来源:发表于2023-01-12 11:34 被阅读0次

读:

tinyxml2::XMLDocument doc;

tinyxml2::XMLElement *pRoot=nullptr;

doc.LoadFile(fileName);

if( 0!=doc.ErrorID() )

{

    return 1;

}

pRoot=doc.FirstChildElement("Root");

if( nullptr==pRoot )

{

    return 1;

}

std::string  str=pRoot->Attribute("itemName");

double  a=pRoot->DoubleAttribute("a");

写:

tinyxml2::XMLDocument doc;

tinyxml2::XMLElement *pRoot=nullptr;

doc.LinkEndChild( doc.NewDeclaration("xml version=\"1.0" encoding=\"UTF-8" standalone=\"yes\") );

pRoot=doc.NewElement("Root");

if( nullptr==pRoot )

{

    return 1;

}

doc.LinkEndChild(pRoot);

pRoot->SetAttribute("itemName",itemName);     // std::string itemName;

pRoot->SetAttribute("a",a);     // int a;

doc.SaveFile( fileName);

相关文章

  • tinyXml2 的基本用法

    读: tinyxml2::XMLDocument doc; tinyxml2::XMLElement *pRoot...

  • 定时器

    setTimeout和clearTimeout基本用法 setInterval和clearInterval基本用法...

  • 2019-11-16

    E战到底DAY14 SUMIF和SUMIFS函数 一.基本用法 SUMIF基本用法 SUMIFS基本用法 SUMI...

  • 11 - 动态数据绑定实现原理

    一、defineProperty 基本用法 1、基本写法: 2、参数 3、descriptor 参数的基本用法 1...

  • 查找函数(Vlookup、Hlookup、Index、Match

    查找函数(Vlookup、Hlookup、Index、Match) 一、基本用法 (1)、VLOOKUP的基本用法...

  • AFNetWorking

    AFNetworking的基本使用 网络请求 AFNetworking的基本用法和NSURLSession的用法基...

  • as 基本用法

    插件安装 plugin auto import 相当于 eclipse ctrl+o 或者as alt+enter...

  • 基本用法

    Installation 安装 npm install vue vue-server-renderer --sav...

  • 基本用法

    html css js

  • 基本用法

    本地与远程:push 命令会把本地仓库推送到远程仓库(比如gitbub,码云)在push之前要与某个远程仓库建立连...

网友评论

      本文标题:tinyXml2 的基本用法

      本文链接:https://www.haomeiwen.com/subject/mbtwcdtx.html