31

我需要一个 Xpath 表达式来选择以某个值开头的值。对于这种情况,我使用的是 id 字段。

@id=[starts-with(name(),'value')

以下不起作用。有没有办法将starts-with命令与标签之间的值一起使用?或者在 xpath 中是否有另一种方法可以选择与已知值匹配的值。

这是我要深入研究的 xml 示例:

    <bean>
<id>AnnotationsBasedJMXAutoExporter</id>
<class>org.springframework.jmx.export.MBeanExporter</class>
<lazy-init>false</lazy-init>
        <property>assembler
                <!-- will create management interface using annotation metadata -->
    <bean>
4

1 回答 1

56

我认为这个 xpath 应该可以工作//id[starts-with(text(),'Annotations')]

于 2013-05-17T11:36:07.183 回答