感谢支持
我们一直在努力

Ubuntu libxml2

1:安装
mkdir /hom/libxml

sudo ./configure ./configure –prefix /home/libxml

make

make install

2:编译
g++ xmlCreator.cpp -o xmlCreator -I /home/libxml/include/libxml2/ -L /home/libxml/lib/ -lxml2

3:例子
#include
#include
#include
int main(int argc, char **argv)
{
xmlDocPtr doc = NULL;
xmlNodePtr root_node = NULL, node = NULL, node1 = NULL;
doc = xmlNewDoc(BAD_CAST “1.0”);
root_node = xmlNewNode(NULL, BAD_CAST “root”);
xmlDocSetRootElement(doc, root_node);
xmlNewChild(root_node, NULL, BAD_CAST “node1”,BAD_CAST “content of node1”);
node=xmlNewChild(root_node, NULL, BAD_CAST “node3″,BAD_CAST”node has attributes”);
xmlNewProp(node, BAD_CAST “attribute”, BAD_CAST “yes”);
node = xmlNewNode(NULL, BAD_CAST “node4”);
node1 = xmlNewText(BAD_CAST”other way to create content”);
xmlAddChild(node, node1);
xmlAddChild(root_node, node);
xmlSaveFormatFileEnc(argc > 1 ? argv[1] : “-“, doc, “UTF-8”, 1);
xmlFreeDoc(doc);
xmlCleanupParser();
xmlMemoryDump();
return(0);

赞(0) 打赏
转载请注明出处:服务器评测 » Ubuntu libxml2
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏