libxml xmlNodePtr to raw xml string?

不羁的心 提交于 2019-11-28 14:06:36

Is xmlNodeDump (or xmlNodeDumpOutput) what you are looking for?

My code I used to dump a node to a string. It's objectiv-c so just change your output as needed.

xmlBufferPtr buffer = xmlBufferCreate();
int size = xmlNodeDump(buffer, myXMLDoc, myXMLNode, 0, 1);

NSLog(@"%d", size);
NSLog(@"%s", buffer->content);

Don't forget to free your buffer again.

One way you could do it definitely is to create a new document, then use xmlDocCopyNode to copy the node into it and serialize it.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!