Poco库之XML操作
来源:互联网 发布:淘宝如何更换账户开店 编辑:程序博客网 时间:2024/05/17 22:41
#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库写XMl
- POCO库之HTTPServer
- Poco c++ Library 之xml 的使用
- 学习Poco库之HTTP下载器
- POCO库Foundation之SharedPtr学习
- Poco数据库操作
- Poco库XML文件的生成与解析
- POCO之Number Format
- Poco 之cppunit解读
- poco之文件系统
- Poco读写XML配置文件示例
- Poco解析XML小例子
- POCO中数据库的操作
- Poco数据库操作用户手册(一)
- Poco数据库操作用户手册(二)
- Poco数据库操作用户手册(一)
- Poco数据库操作用户手册(二)
- coder
- github避免每次输入账户密码
- [ACM]模拟大数加法
- Qt之json解析
- dx命令详解
- Poco库之XML操作
- Poco之ftp目录切换与创建
- networkRequest
- iOS9 通讯录(无界面的和有界面的)
- QTcpsocket 实现FTP
- C++指针例
- 数字图像处理二
- Poco版信号槽
- poco异步等待ActiveResult