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 ...
随机推荐
- validatebox实现多重规则验证
作为Easyui的校验插件没有实现多重校验能力是一种缺憾.比如说,既要限制格式为email,同时要求最长长度为20,我们就要扩展一种规则,而对长度的要求很容易变化,如果变成要求30,我们又得扩张一种规 ...
- WPF WebBrowser
XAML <Window x:Class="WpfApplication5.Window1" xmlns="http://schemas.microso ...
- [Whole Web] [AngularJS] Localize your AngularJS Application with angular-localization
It is best to start your application's localization efforts early in development, even if you only s ...
- [Javascript] The Array filter method
One very common operation in programming is to iterate through an Array's contents, apply a test fun ...
- cocos2dx3.1.1+cocosstudio+lua问题总结
一.DeprecatedEnum.lua no value _G.LAYOUT_ABSOLUTE = ccui.Type.ABSOLUTE _G.LAYOUT_LINE ...
- 【转】针对iOS VS. Android开发游戏的优劣——2013-08-25 17
http://game.dapps.net/gamedev/experience/8670.html 问题:如果你正在一个新工作室开发一款新的平板/手机游戏,你会选择iOS还是Android? 回答: ...
- HDU1010(bfs)
#include <stdio.h>#include <iostream>#include <string.h>#include <stdlib.h>u ...
- Asp.Net分页存储过程
SQL分页语句 一.比较万能的分页: sql代码: 1 2 3 select top 每页显示的记录数 * from topic where id not in (select top (当前的 ...
- php测试oracle链接是否成功
$conn = oci_connect('eoffice', 'hdujiedian', '//192.168.100.21/hziee'); if (!$conn) { $e = oci_error ...
- flash wmode="window&qu…
引用一段话:opaque和tranparent由于都是无窗口内渲染模式,能很好的实现各层的遮挡,和一般div元素没有太大区别,而window.direct模式在现在看来,是没有任何办法实现被DHTML ...