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

查看:25
本文介绍了如何使用 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(),它将接受一个以 null 结尾的字符串(xmlChar/unsigned char)并像使用 xmlParseFile().

这篇关于如何使用 libxml2 库在 c 中解析 XML 字符串而不是 XML 文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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