今天试用了xerces-c , 我觉得果然好像还是不如Java版本的XML api好用。当然是个人愚见。对于创建XML实例还是比较简单的,而要输出到屏幕则着实费了一番脑筋。在baidu、google上都难以找到实例。后来 我想到它的samples中有类似的例子,就下载源码来研究。最后做了一个非常简单的版本。代码如下:
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/framework/StdOutFormatTarget.hpp>
#include <iostream>
using namespace xercesc;
int main(int argc, char* argv[])
{
try {
XMLPlatformUtils::Initialize();
}
catch (const XMLException& toCatch) {
// Do your failure processing here
return 1;
}
XMLCh str[10];
// Do your actual work with Xerces-C++ here.
XMLString::transcode("Core", str, 9);
DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(str);//DOMImplementa
使用xerces-c生成XML并输出
最新推荐文章于 2018-07-31 11:59:01 发布