Xpath 和通配符
我尝试了几种组合但没有成功。该数据的完整 xpath 为 .//*[@id='detail_row_seek_37878']/td
问题是每个节点的数字部分“37878”发生变化,因此我无法使用 foreach循环遍历节点。有没有办法使用通配符并将 xpath 减少为 .//*[@id='detail wildcard
,以绕过绝对值部分?我在此使用 html 敏捷包。
HtmlNode ddate = node.SelectSingleNode(".//*[@id='detail_row_seek_37878']/td");
I have tried several combinations without success. The full xpath to that data is .//*[@id='detail_row_seek_37878']/td
The problem is the number portion '37878' changes for each node and thus I can't use a foreach to loop through the nodes. Is there some way to use a wildcard and reduce the xpath to .//*[@id='detail wildcard
, in an effort to bypass the absolute value portion? I am using html agility pack on this.
HtmlNode ddate = node.SelectSingleNode(".//*[@id='detail_row_seek_37878']/td");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
提取不变的部分:
相关技术和功能
匹配
id
属性在第 7 个位置包含字符串_row_
的元素字符:匹配
id
属性在任意位置包含文本detail_
的元素:匹配
id<的元素/code> 属性以文本
detail_row_seek
结尾:Extract the portion that doesn't change:
Related Techniques and Functions
To match elements whose
id
attribute contains the string_row_
at the 7th character:To match elements whose
id
attribute contains the textdetail_
at any position:To match elements whose
id
attribute ends with the textdetail_row_seek
: