关键词不能为空

当前您在: 主页 > 英语 >

Easy XML使用指南

作者:高考题库网
来源:https://www.bjmy2z.cn/gaokao
2021-02-28 05:18
tags:

-

2021年2月28日发(作者:批评指正)


Easy XML


使用指南



文档信息



项目名称



需求编号



文档编号



版本号



修改记录



修改日期























Easy XML -


通用


XML


解析器





1.0


作者



审核人



曾臻




创建日期



审核日期



2006-3-10



作者







































说明





















审核人



1



引言



Easy XML


是为


C++


开发的


XML< /p>


解析器,它利用了


C++


的函数重载、函 数对象等语言特性方便了程序员对


XML


解析代码的编写。本库 不依赖于其它的


XML


解析器(如


XM L4C



,实现上完全基于


STL




2



指南



2.1



例子



2.1.1



XML


的生成



下面这段代码演示了怎样使用


Easy XML


来生成


XML


文档


:


#include


#include


#include


#include



void main()


{


//create root element


Element info(



//create and assemble pet elements


Element pet(


ribute(


(


(


(


(


ld(pet);


pet(


pet(


pet(


pet(


pet(


ld(pet);



//create and assemble band elements


Element band(


ribute(


(


(


(


Element member(


ld(


(


ld(member);


member[


member[


ld(member);


ld(band);



//generate xml string


string outXml;


Parser parser;


parser<>outXml;



//output to xml file


ofstream of(


of<


();


}



生成的



内容如下:



2.1.2



XML


的解析



下面这段代码演示了怎样使用


Easy XML


来解析


XML


文档


:


#include


#include


#include


#include



void main()


{


//input from xml file


ifstream file(


string inXml;


while(!())


inXml+=();


();



//parse xml string


Parser parser;


Element info;


parser<>info;



//access element through operator


cout<<


cout<<




//access element through reference


Element& mouse=info[


cout<<



//access element through index


cout<


Element& pet=info[


for(long index=0;index


{


Element& e=pet[index];


cout<<


cout<<


cout<<


cout<<


cout<<


}



//access element through iterator


cout<


Element& member=info[


for(Element* pe=lement();eElements();pe=ement())


{


Element& e=*pe;


cout<


}


}

-


-


-


-


-


-


-


-



本文更新与2021-02-28 05:18,由作者提供,不代表本网站立场,转载请注明出处:https://www.bjmy2z.cn/gaokao/678828.html

Easy XML使用指南的相关文章