xpath 查找具有最大属性的节点 [英] xpath to find the node with maximum attributes
本文介绍了xpath 查找具有最大属性的节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个这样的 xml 结构.
I have an xml structure like this.
<pages>
<page a="1">111</page>
<page a="1" b="2">222</page>
<page a="1">333</page>
<page a="1" b="2" c="3" d="4">444</page>
<page a="1" b="2">555</page>
<page a="1">666</page>
</pages>
Xpath 应返回值 444,因为该节点已获得最大数量的属性.我们应该怎么做?请帮忙.
Xpath should return the value 444 since that node has got the maximum number of attributes. How can we do this? Please help.
推荐答案
根据 http://wiki.orbeon.com/forms/doc/developer-guide/xpath-2-0-support Orbeon 支持 XPath 2.0,因此您可以执行诸如 /pages 之类的操作/page[count(@*) eq max(/pages/page/count(@*))]
.
According to http://wiki.orbeon.com/forms/doc/developer-guide/xpath-2-0-support Orbeon supports XPath 2.0 so you can do stuff like /pages/page[count(@*) eq max(/pages/page/count(@*))]
.
这篇关于xpath 查找具有最大属性的节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文