且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用xpath选择以下同级/xml标记

更新时间:2022-11-26 18:04:10

我将如何完成下一个兄弟姐妹 有没有更简单的方法 这个吗?

How would I accomplish the nextsibling and is there an easier way of doing this?

您可以使用:

tr/td[@class='name']/following-sibling::td

但我宁愿直接使用:

tr[td[@class='name'] ='Brand']/td[@class='desc']

这是假定:

  1. 将对其进行评估的XPath表达式的上下文节点是所有tr元素的父级-在您的问题中未显示.

  1. The context node, against which the XPath expression is evaluated is the parent of all tr elements -- not shown in your question.

每个tr元素只有一个td属性的值为'name',只有一个td属性的值为'desc'.

Each tr element has only one td with class attribute valued 'name' and only one td with class attribute valued 'desc'.