问题描述
libxml2的文档中的所有例子使用外部XML文件被提及。如果我需要分析在它的XML内容的字符串?难道真的有可能在libxml2的C库,或唯一的解决方案将采取字符串保存到文件并发送该文件名作为参数传递给下面的功能。但是,这将严重影响性能。
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);
是否有任何libxml2的内置功能解析字符数组?
Are there any inbuilt functions in libxml2 to parse character arrays?
推荐答案
您可以使用,这将需要一个空终止(的XMLCHAR / unsigned char型)串并解析它完全一样,如果它是从使用文件<$c$c>xmlParseFile()$c$c>.
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()
.
这篇关于如何使用libxml2库来分析在C XML字符串,而不是XML文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!