一个简单的 C XML 解析器 [英] A simple C XML parser
问题描述
我需要从 C 程序中读取 XML 格式的文档,并从中提取元素及其值.例如在下面的代码中:
I need to read an XML formatted document from a C program and extract from it the elements and their values. For example in the following code:
<user name="Mark">
<param name="Age" value="21"/>
<param name="Country" value="NL"/>
</user>
我需要提取:name = Mark
、Age = 21
和 Country = NL
.
I need to extract: name = Mark
, Age = 21
and Country = NL
.
直到今天我一直在手动进行解析,这很痛苦.
Up until today I've been doing this parsing manually which is a pain.
我不在乎文件是正确的 XML"还是其他所有内容,我不在乎 DTD 或其他标准 XML 要求.我只需要读取和解析值.
I don't care whether the file a "proper XML" or all that, I don't care about DTD's or other standard XML requirements. I just need to read and parse the values.
有没有人知道除 lib eXpat 之外的库可以执行此操作或代码执行此操作?
Does anyone know of a library other than lib eXpat to do this or code to do this?
谢谢!
推荐答案
Mini-XML 看起来很有前景
Mini-XML looks promising
这篇关于一个简单的 C XML 解析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!