小编Tha*_*i J的帖子

如何在XPath中查找特定类型的所有节点

假设我的view.xml中有以下表单数据实例:

<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
xmlns:exforms="http://www.exforms.org/exf/1-0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xhtml:head>
<xforms:instance id="instanceData">
    <form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <fruits>
     <fruit>
        <fruit-name>Mango</fruit-name>
     </fruit>
     <fruit>
        <fruit-name>Apple</fruit-name>
     </fruit>
     <fruit>
        <fruit-name>Banana</fruit-name>
     </fruit>
</fruits>
</form>
</xforms:instance>
</xhtml:head>
Run Code Online (Sandbox Code Playgroud)

我想从上面的实例中选择所有水果名称.我尝试了以下方法,但它总是选择第一个水果.

instance('instanceData')/fruits/fruit[*]/fruit-name
instance('instanceData')/fruits/fruit/fruit-name
instance('instanceData')/fruits/fruit[position()>0]/fruit-name
Run Code Online (Sandbox Code Playgroud)

请提供一种在XPATH中克服此问题的方法

xpath xforms orbeon

6
推荐指数
1
解决办法
9475
查看次数

标签 统计

orbeon ×1

xforms ×1

xpath ×1