平台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操作的更多相关文章

  1. POCO库——Foundation组件之核心Core

    核心Core: Version.h:版本控制信息,宏POCO_VERSION,值格式采用0xAABBCCDD,分别代表主版本.次版本.补丁版本.预发布版本: Poco.h:简单地包含了头文件Found ...

  2. 【Java EE 学习 33 上】【JQuery样式操作】【JQuery中的Ajax操作】【JQuery中的XML操作】

    一.JQuery中样式的操作 1.给id=mover的div采用属性增加样式.one $("#b1").click(function(){ $("#mover" ...

  3. Python XML操作

    XML(可扩展性标记语言)是一种非常常用的文件类型,主要用于存储和传输数据.在编程中,对XML的操作也非常常见. 本文根据python库文档中的xml.etree.ElementTree类来进行介绍X ...

  4. Python 标准库之 xml.etree.ElementTree

    Python 标准库之 xml.etree.ElementTree Python中有多种xml处理API,常用的有xml.dom.*模块.xml.sax.*模块.xml.parser.expat模块和 ...

  5. POCO库中文编程参考指南(4)Poco::Net::IPAddress

    POCO库中文编程参考指南(4)Poco::Net::IPAddress 作者:柳大·Poechant 博客:Blog.CSDN.net/Poechant 邮箱:zhongchao.ustc#gmai ...

  6. POCO库中文编程参考指南(3)Poco::Net::Socket

    POCO库中文编程参考指南(3)Poco::Net::Socket 作者:柳大·Poechant 博客:Blog.CSDN.net/Poechant 邮箱:zhongchao.ustc#gmail.c ...

  7. POCO库中文编程参考指南(1)总览

    POCO库中文编程参考指南(1)总览 作者:柳大·Poechant 博客:Blog.CSDN.net/Poechant 邮箱:zhongchao.ustc#gmail.com (# -> @) ...

  8. POCO库中文编程参考指南(8)丰富的Socket编程

    POCO库中文编程参考指南(8)丰富的Socket编程 作者:柳大·Poechant 博客:Blog.CSDN.net/Poechant 邮箱:zhongchao.ustc#gmail.com (# ...

  9. POCO库——Foundation组件概述

    Foundation组件作为POCO库的基础组件,主要包含了核心Core.缓存Cache.加解密Crypt.日期时间DateTime.动态类型Dynamic.事件events.文件系统Filesyst ...

随机推荐

  1. Wbemtest查询

    运行wbemtest,打开后连接命名空间,默认为“root\cimv2”,可以连接到”IIS管理命名空间(此为Windows Server 2008 R2)“ 查看该命名空间下所有可用的类:单击“枚举 ...

  2. 初涉A*剪枝

    挖坑防忘,天亮补题解. #include <algorithm> #include <iostream> #include <cstring> #include & ...

  3. 硬菜点播台 | MySQL阿里实践经典案例之参数调优最佳实践

    http://mp.weixin.qq.com/s?__biz=MzA4NjI4MzM4MQ%3D%3D&mid=512708319&idx=1&sn=6af5f424d7cd ...

  4. HDU1241(bfs)JAVA

    import java.util.Scanner;public class Main1241 { public static void main(String[] args) { Scanner ci ...

  5. 集合练习——List部分

    利用ArrayList 1.存储多个员工信息,包括工号,姓名,年龄,入职时间,逐条打印所有员工姓名,并输出员工个数. package CollectionPart; import java.util. ...

  6. [置顶] asp.net(c#)中相对路径(虚拟路径)和物理磁盘路径的转换

    物理路径就是磁盘路径,也就是说是在磁盘上的位置,虚拟路径也就是web页面上的路径,是相对于应用程序而言的 /// <summary> /// 将物理路径转换成相对路径 /// </s ...

  7. [转]前端开发必备 40款优秀CSS代码编写工具推荐

    编写工具地址如下 英文地址:http://webtoolsdepot.com/40-css-tools-to-improve-your-productivity/ 中文地址:http://www.cs ...

  8. css 多栏自适应布局

    在页面重构中,我们经常会需要实现多栏布局,例如n栏固定宽度 + m栏自适应宽度的组合,绝对布局+padding+百分比宽度是容易想到的比较暴力的解决方法,但是作为未来的"工程师", ...

  9. ActionBar只显示图标不显示文字

    问题:ActionBar菜单项android:showAsAction设置为android:showAsAction="always|withText"或者android:show ...

  10. 销毁session

    session运行在服务器是单用户,每个session都有一个唯一的sessionid 用法:session.setAttribute("userName", "张三丰& ...