根据前缀选择属性的 XPath 表达式是什么? [英] What’s the XPath expression to select an attribute based on its prefix?
问题描述
我需要选择一个具有我只知道部分值的 id 属性的节点.
I need to select a node with a id attribute that I only know part of the value.
如果我有多个 If I have several 我只想选择以 I only want to select the id's that start with 我试过了: 但它不起作用. 有什么帮助吗?谢谢. XPath 1.0 函数列表:http://www.edankert.com/xpathfunctions.html一个> A list of XPath 1.0 functions: http://www.edankert.com/xpathfunctions.html 如果您的实现支持 XPath 2.0,您会得到很多其他实现. If your implementations supports XPath 2.0, you get a lot of other ones. 这篇关于根据前缀选择属性的 XPath 表达式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! 元素:
<tr>
elements:<tr id="foobar[1234]"></td><tr id="foobar[1235]"></td><tr id="foobar[1236]"></td><tr id="bar[1]"></td><tr id="foobar[1237]"></td><tr id="bar[12]"></td>
foobar
开头的 ID.foobar
.//tr[@id='foobar*']
推荐答案
//tr[starts-with(@id,'foobar')]
登录
关闭