作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我可以通过这种方式使用ezxml_get函数来计算父标签books内的子book标签的数量吗?如果没有找到子标签,函数返回NULL。
int books_cnt = 0;
for(i=0; i<100; i++)
{
if((ezxml_get(xml_file, "books", 0, "book", i) != NULL)
{
books_cnt++;
}
}
这就是 xml 的样子
<books>
<book>
</book>
<book>
</book>
.
.
.
.
</books>
最佳答案
是的,你可以。你没有尝试过吗?快速浏览一下 ezxml page ,使用 ezxml_child()
并在计算自己的同时循环遍历链表可能会更好(就性能而言)
[编辑]为了完全澄清......该网站提供了以下示例代码:
for (team = ezxml_child(f1, "team"); team; team = team->next) {
teamname = ezxml_attr(team, "name");
for (driver = ezxml_child(team, "driver"); driver; driver = driver->next) {
printf("%s, %s: %s\n", ezxml_child(driver, "name")->txt, teamname,
ezxml_child(driver, "points")->txt);
}
}
所以只需使用外部循环和计数之类的东西,例如:
int i = 0;
for (book = ezxml_child(xml_file, "book"); book; book = book->next) ++i;
关于c - EZXML C 解析 API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31605003/
如果我有多个标签,如何解析值,如上面的代码。 Abcd 112 Juan Pablo Montoya 60 Kimi Raikkonen 112 EFGH 60 我能够
我可以通过这种方式使用ezxml_get函数来计算父标签books内的子book标签的数量吗?如果没有找到子标签,函数返回NULL。 int books_cnt = 0; for(i=0;
我对 EZXML 解析器的可能性有点困惑。当我解析 ASCII 范围内的字符时,一切都运行良好,但是当我尝试解析非 ASCII 字符 (UTF-8) 时,我什么也没得到。 EZXML 是否仅适用于标准
我是一名优秀的程序员,十分优秀!