给定锚文本子串的链接的XPath

时间:2017-10-29 01:17:02

标签: html xml xpath

我有这个不那么整洁的HTML片段:

<a href="#" onclick="JavaScript:fnActivity('-247239453','C');return false;">
    ACCOUNT
    -
    <span class="td-copy-nowrap">4575 <span class="td-copy-nowrap">6017785<span class="td-link-icon">›</span></span></span>
</a>

我有这个元信息:6017785

我可以编写一个xpath选择器,根据这个数字找到链接(a)元素吗?

我试过了//span[contains(text(), '6017785')]/ancestor::a,但它似乎没有用,可能是因为跨度内的跨度,数字附近?

1 个答案:

答案 0 :(得分:1)

这个XPath,

a

将选择其字符串值包含子字符串6017785的所有const userSchema = new Schema( { //Username _id: { type: String, unique: true }, name: { type: String, required: 'Name is required.' }, groups: [{ type: Schema.Types.ObjectId, ref: 'groups'}] }, ); 个元素。

另见: