【问题标题】:How to find specific child node in xml file using libxml2如何使用 libxml2 在 xml 文件中查找特定的子节点
【发布时间】:2021-01-07 16:44:10
【问题描述】:

我有一个这样的 xml 文件

<file>
    <a>thisisa</a>
    <b>thisisb</b>
    <c>
         <c1 param1="team1" place="winner" game="cricket">
             www.team1.com
         </c1>
         <c2 param1="team2" place="runner" game="football">
             www.team2.com
         </c2>
    </c>       
</file>

我想使用 C 语言中的 libxml2 打印此文件中的所有游戏。(如本例中的板球和足球)。我尝试使用 xmlFirstElementChild。但这增加了解决方案的时间复杂度,因为它需要 while 循环。有没有更好的解决方案来实现这一点?

【问题讨论】:

标签: c xml-parsing libxml2


【解决方案1】:

您可以使用xmlfindchild(node parent,node child ,child prop id)

【讨论】:

  • 这个方法在libxml2的什么地方?我在文档中找不到任何参考。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多