pugixml 学习笔记一 加载文件
2014-01-24 18:27
423 查看
编程环境 VC 6.0
代码下载地址: http://download.csdn.net/detail/u012607841/6881367
// pugixmltest.cpp : Defines the entry point for the console application. // #include "stdafx.h" //可以是相对路径,或者绝对路径 bool LoadFromFile(const char * szXmlFileName) { pugi::xml_document doc; pugi::xml_parse_result result = doc.load_file(szXmlFileName); std::cout << "Load result: " << result.description() <<std::endl << "name.attrib = " << doc.child("Name").attribute("age").value() << std::endl; return true; } bool LoadFromBuffer() { const char *szBuffer="<?xml version=\"1.0\"?><Name age=\"10\">good</Name>"; pugi::xml_document doc; if (!doc.load_buffer(szBuffer,strlen(szBuffer))) return false; std::cout<< "name.attrib = " << doc.child("Name").attribute("age").value() << std::endl; return true; } bool LoadFromMem() { const char *szBuffer="<?xml version=\"1.0\"?><Name age=\"10\">good</Name>"; pugi::xml_document doc; if (!doc.load(szBuffer)) return false; std::cout<< "name.attrib = " << doc.child("Name").attribute("age").value() << std::endl; return true; } bool LoadFromStream() { std::ifstream stream("tree.xml"); pugi::xml_document doc; if (!doc.load(stream)) { return false; } std::cout<< "name.attrib = " << doc.child("Name").attribute("age").value() << std::endl; return true; } int main(int argc, char* argv[]) { //LoadFromFile("tree.xml"); //LoadFromBuffer(); //LoadFromMem(); LoadFromStream(); return 0; }
代码下载地址: http://download.csdn.net/detail/u012607841/6881367
相关文章推荐
- pugixml 学习笔记一 加载文件
- 【Spring学习笔记-2】Myeclipse下第一个Spring程序-通过ClassPathXmlApplicationContext加载配置文件
- spring学习笔记(3)——配置文件applicationContext.xml的加载
- pugixml学习笔记2 保存文件
- StringTemplate.Net 学习笔记(7):加载模板文件
- StringTemplate.Net 学习笔记(8):加载模板组文件
- SqlMapConfig.xml配置文件---Mybatis学习笔记(七)
- Android 个人学习笔记之--- Pull解析XML文件
- Struts2.x 学习笔记 之 通过超链接动态加载国际化资源文件
- js便签笔记(8)——js加载XML字符串或文件
- Windows Phone 7 开发探索笔记7——加载XML文件
- StringTemplate.Net 学习笔记(7):加载模板文件
- solr7.1.0学习笔记(8)---配置文件managed-schema(schema.xml)-analyzer,tokenizer
- 逆向分析学习笔记--PE文件加载流程
- AndroidManifest.xml 文件配置学习笔记
- 学习笔记——JavaScript操作XML文件
- Android 个人学习笔记之---SAX解析XML文件
- Spring 学习笔记(5)—— 简化xml配置文件的配置方式
- C++Builder学习笔记5.1(连接数据库,读写配置文件,加载DLL)
- SAP BW平面文件特征数据的加载——视频学习笔记04和05