以这个xml文件为例:
<xyz version="1.0">
<lives>
<life key="1">
<section name="Application123">
<disclosure type="alcohol">
<disclosure type="build">
<internal>
<height> data </height>
<weight>data</weight>
</internal>
</disclosure>
<disclosure type="drug">
<disclosure type="tobacco">
</section>
</life>
</lives>
</xyz>我想要一个查询,它给我提供路径以及属性名称和属性值。假设,我查询"build",然后我想要所有的路径如下:
xyz/lives/life[key="1"]/section[name="Application123"]/disclosure[type="build"]/internal/height我可以使用(在xquery中工作)获得路径
declare function local:path-to-node( $nodes as node()* ) as xs:string* {
$nodes/string-join(ancestor-or-self::*/name(.), ''/'')如下所示:
xyz/lives/life/section/disclosure/internal/height但是我还需要包含属性名称和它们的值。朋友,有什么建议吗?
发布于 2016-06-16 01:05:54
在XPath中,属性之前需要一个@。
xyz/lives/life[@key='1']/section[@name='Application123']/disclosure[@type='build']/internal/heighthttps://stackoverflow.com/questions/37837151
复制相似问题