I have written sxmlc to be as simple as possible and I know people use it in routers, to perform in-place parsing of web queries.
Unfortunately (and I'm 5 years late...) it does use memory allocation, though kept at a minimum: one buffer to read each "XML line" (what lies between < and >, sorry ;)), and many small buffer to keep track of the tag name, attributes names and values, and text (though I always wanted to use char[16] or so for those).
And it makes use of strdup/strcpy and such.
As I want that anybody can use it freely, the licence is BSD.
Xerces-C library would be optimal to use, in this scenario.
If it is going to be pretty small XML, why not generate programatically, using sprintf or other stuff and use string extracting functions to parse the same. But as mentioned earlier, if little big, would suggest to use Xerces-c Library, as it is open source
发布评论
评论(6)
我不知道动态内存分配,但标准的 C XML 解析器是 expat,它是底层库对于那里的许多解析器。
I don't know about dynamic memory allocation, but a standard C XML parser is expat, which is the underlying library for a number of parsers out there.
我不确定,但也许 Mini-XML:轻量级 XML 库 会帮助您:
I am not sure but perhaps Mini-XML: Lightweight XML Library will help you:
您可以使用 ASN.1 XER 编码器; http://lionet.info/asn1c/ 有一个免费的
You could use an ASN.1 XER encoder; there's a free one at http://lionet.info/asn1c/
您可以使用 “ rel="nofollow">侏儒。
You could use the one from Gnome.
我编写的 sxmlc 尽可能简单,我知道人们在路由器中使用它,以在-Web 查询的位置解析。
不幸的是(我晚了 5 年……)它确实使用了内存分配,尽管保持在最低限度:一个缓冲区来读取每个“XML 行”(位于
<
和之间的内容) >>
,抱歉;)),还有许多小缓冲区来跟踪标签名称、属性名称和值以及文本(尽管我一直想使用char[16]
或者对于那些)。它利用了
strdup
/strcpy
等。因为我希望任何人都可以自由使用它,所以许可证是 BSD。
I have written sxmlc to be as simple as possible and I know people use it in routers, to perform in-place parsing of web queries.
Unfortunately (and I'm 5 years late...) it does use memory allocation, though kept at a minimum: one buffer to read each "XML line" (what lies between
<
and>
, sorry ;)), and many small buffer to keep track of the tag name, attributes names and values, and text (though I always wanted to usechar[16]
or so for those).And it makes use of
strdup
/strcpy
and such.As I want that anybody can use it freely, the licence is BSD.
在这种情况下,Xerces-C 库是最佳选择。
如果它是非常小的 XML,为什么不使用 sprintf 或其他东西以编程方式生成并使用字符串提取函数来解析它。 但正如前面提到的,如果规模不大,会建议使用 Xerces-c 库,因为它是开源的
Xerces-C library would be optimal to use, in this scenario.
If it is going to be pretty small XML, why not generate programatically, using sprintf or other stuff and use string extracting functions to parse the same. But as mentioned earlier, if little big, would suggest to use Xerces-c Library, as it is open source