Poco库之XML操作
平台ubuntu14.04LTS Poco版本:Poco1.6.1
#include <Poco/DOM/Text.h>
#include <Poco/DOM/Element.h>
#include <Poco/DOM/Comment.h>
#include <Poco/DOM/ProcessingInstruction.h>
#include <Poco/DOM/Attr.h>
#include <Poco/DOM/Document.h>
#include <Poco/DOM/DOMWriter.h>
#include <Poco/XML/XMLWriter.h>
#include <Poco/AutoPtr.h>
#include <Poco/FileStream.h>
using Poco::AutoPtr;
int main()
{
AutoPtr<Poco::XML::Document> pDoc = new Poco::XML::Document;
AutoPtr<Poco::XML::Element> myRoot = pDoc->createElement("Root");
AutoPtr<Poco::XML::Element> myChild = pDoc->createElement("Child");
AutoPtr<Poco::XML::Element> myGrandChild = pDoc->createElement("GrandChild");
AutoPtr<Poco::XML::Text> nameNode = pDoc->createTextNode("my_name_is_xiaoqiang");
AutoPtr<Poco::XML::ProcessingInstruction> pi = pDoc->createProcessingInstruction("xml","version='1.0' encoding='UTF-8'" );
AutoPtr<Poco::XML::Comment> comm = pDoc->createComment("new_day");
myGrandChild->appendChild(nameNode);
myChild->appendChild(myGrandChild);
myRoot->appendChild(myChild);
pDoc->appendChild(pi);
pDoc->appendChild(comm);
pDoc->appendChild(myRoot);
Poco::XML::DOMWriter write;
write.setOptions(Poco::XML::XMLWriter::PRETTY_PRINT);
Poco::FileStream ofs("./example.txt",std::ios::in);
write.writeNode(ofs,pDoc);
return 0;
}
Notes:
LIBS += -lPocoFoundation -lPocoXML
Poco库之XML操作的更多相关文章
- POCO库——Foundation组件之核心Core
核心Core: Version.h:版本控制信息,宏POCO_VERSION,值格式采用0xAABBCCDD,分别代表主版本.次版本.补丁版本.预发布版本: Poco.h:简单地包含了头文件Found ...
- 【Java EE 学习 33 上】【JQuery样式操作】【JQuery中的Ajax操作】【JQuery中的XML操作】
一.JQuery中样式的操作 1.给id=mover的div采用属性增加样式.one $("#b1").click(function(){ $("#mover" ...
- Python XML操作
XML(可扩展性标记语言)是一种非常常用的文件类型,主要用于存储和传输数据.在编程中,对XML的操作也非常常见. 本文根据python库文档中的xml.etree.ElementTree类来进行介绍X ...
- Python 标准库之 xml.etree.ElementTree
Python 标准库之 xml.etree.ElementTree Python中有多种xml处理API,常用的有xml.dom.*模块.xml.sax.*模块.xml.parser.expat模块和 ...
- POCO库中文编程参考指南(4)Poco::Net::IPAddress
POCO库中文编程参考指南(4)Poco::Net::IPAddress 作者:柳大·Poechant 博客:Blog.CSDN.net/Poechant 邮箱:zhongchao.ustc#gmai ...
- POCO库中文编程参考指南(3)Poco::Net::Socket
POCO库中文编程参考指南(3)Poco::Net::Socket 作者:柳大·Poechant 博客:Blog.CSDN.net/Poechant 邮箱:zhongchao.ustc#gmail.c ...
- POCO库中文编程参考指南(1)总览
POCO库中文编程参考指南(1)总览 作者:柳大·Poechant 博客:Blog.CSDN.net/Poechant 邮箱:zhongchao.ustc#gmail.com (# -> @) ...
- POCO库中文编程参考指南(8)丰富的Socket编程
POCO库中文编程参考指南(8)丰富的Socket编程 作者:柳大·Poechant 博客:Blog.CSDN.net/Poechant 邮箱:zhongchao.ustc#gmail.com (# ...
- POCO库——Foundation组件概述
Foundation组件作为POCO库的基础组件,主要包含了核心Core.缓存Cache.加解密Crypt.日期时间DateTime.动态类型Dynamic.事件events.文件系统Filesyst ...
随机推荐
- [2014.5.22][UBUNTU]Ubuntu与Windows系统时间不同步的问题
安装Ubuntu+Windows双系统时会遇到Windows和Ubuntu系统时间不同步的问题,这是由于Windows系统默认读取主板bios等硬件系统时间作为OS的当地时间;而MAc,Linux类的 ...
- 13 引用WINAPI
[System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SetWind ...
- Android两个控件叠在一起,如何让被挡住的控件显示出来
Android两个控件叠在一起,如何让被挡住的控件显示出来 问题 : 两个控件叠在一起,如何让被挡住的控件显示出来? 比如A,B两个控件,A被B挡住,目前A要显示出来,B不能被隐藏,A的高度只有那么一 ...
- dubbo使用方法
dubbo使用方法. Dubbo采用全Spring配置方式,透明化接入应用,对应用没有任何API侵入,只需用Spring加载Dubbo的配置即可,Dubbo基于Spring的Schema扩展进行加载. ...
- android110 jni01
##交叉编译(编译就是编译成汇编指令,使得电脑能够识别,比如windows平台模拟linux平台编译出来得程序可以在linux上运行.) * 在一个平台下,编译出另一个平台能够执行的二进制的代码 * ...
- MVC - Ajax
Ajax表单 使用Ajax.BeginForm方法即可开启Ajax表单 Ajax.BeginForm() 参数1:Action名参数2:使用AjaxOptions实例设定异步请求的属性 new Aja ...
- 全球5大安全工具Linux发行版本
全球5大安全工具Linux发行版本http://automationqa.com/forum.php?mod=viewthread&tid=2314&fromuid=21
- oracle EBS中使用PLSQL提交"关闭离散"并发请求
declare l_request_id number; l_return_flag boolean; l_num_user_id number; l_num_resp_id number; l_nu ...
- find命令基本使用一览
find命令相对于locate这种非实时查找的搜索命令,大大增加了我们搜索的便捷度以及准确性:并且能够方便的帮助我们对大文件.特定类型的文件查找与删除,特别是有超多小碎文件的时候,更是方便至极.... ...
- 【转载】NIO服务端序列图
步骤一:打开ServerSocketChannel,用于监听客户端的连接,它是所有客户端连接的父管道,代码示例如下: ServerSocketChannel acceptorSvr = ServerS ...