XPath:返回具有特定属性的第一次见面的子对象
具有以下层次结构:XPath:返回具有特定属性的第一次见面的子对象,xpath,return,parent-child,attr,Xpath,Return,Parent Child,Attr,具有以下层次结构: Parent1 --> child1(@name = 'abc') --> child2(@name = 'xyz') --> child3(@name = 'qqq') Parent2 --> child1 --> child2(@name = 'yui') XPath返回所需的以下节点: child1来自父母1 和 child2来自父母2 规则如下: return第一次出现仅子具有特定属性的,在本例
Parent1
--> child1(@name = 'abc')
--> child2(@name = 'xyz')
--> child3(@name = 'qqq')
Parent2
--> child1
--> child2(@name = 'yui')
XPath返回所需的以下节点:
child1来自父母1
和
child2来自父母2
规则如下:return第一次出现仅子具有特定属性的,在本例中为
@name
注意:first()
/root/node()/node()[@name][position()=1]
使用此XML:
<?xml version="1.0" encoding="utf-8"?>
<root>
<parent1>
<child1 name="abc"></child1>
<child2 name="xyz"></child2>
<child3 name="qqq"></child3>
</parent1>
<parent2>
<child1></child1>
<child2 name="yui"></child2>
</parent2>
</root>
返回:
Element='<child1 name="abc" />'
Element='<child2 name="yui" />'
Element=''
元素=“”
感谢您的提示,不幸的是,对于JCR XPath,此函数尚未实现,无论如何,这在其他上下文中是可行的