How to parse a XML string instead of XML doc in c using libxml2 library

回眸只為那壹抹淺笑 提交于 2019-12-04 00:34:50

问题


All the examples in libxml2 documentation libxml tutorial are mentioned using external XML files. What if I need to parse a string with XML content in it? Is it really possible in libxml2 C library, or the only solution would be taking the string saving it to the file and sending that file name as argument to the below function. But it would seriously effect the performance.

doc = xmlParseFile(docname);

Are there any inbuilt functions in libxml2 to parse character arrays?


回答1:


You can use xmlParseDoc(), which will take a null terminated string (of xmlChar / unsigned char) and parse it exactly as if it were read from a file using xmlParseFile().



来源:https://stackoverflow.com/questions/12554792/how-to-parse-a-xml-string-instead-of-xml-doc-in-c-using-libxml2-library

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