如何使用libxml2库来分析在C XML字符串,而不是XML文档 [英] How to parse a XML string instead of XML doc in c using libxml2 library

查看:162
本文介绍了如何使用libxml2库来分析在C XML字符串,而不是XML文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

libxml2的文档中的所有例子 libxml的教程使用外部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?

推荐答案

您可以使用 xmlParseDoc() ,这将需要一个空终止(的XMLCHAR / unsigned char型)串并解析它完全一样,如果它是从使用文件<读href=\"http://www.xmlsoft.org/html/libxml-parser.html#xmlParseFile\"><$c$c>xmlParseFile().

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文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆