【问题标题】:HTML Agility Pack Find ids starting withHTML Agility Pack 查找以
【发布时间】:2011-08-30 12:29:29
【问题描述】:

我在 XPath 上完全是个菜鸟,我正在做从网站获取数据的应用程序,我需要找到 2 件事:

1- 所有以ctl00_Main_GridView_lieutenants开头的span标签

2-span上父标签的href.... errr..我会尽量解释:

<a href="something.html"><span id="ctl00_Main_GridView_lieutenants_ctl03_lbl_nick">Text</span></a>

我需要文本和链接;)

【问题讨论】:

  • 你也可以考虑使用 jQuery(代替)
  • 不使用 WebForms 的另一个理由...

标签: c# .net xml xpath html-agility-pack


【解决方案1】:
//span[starts-with(@id, 'ctl00_Main_GridView_lieutenants')]

选择@idctl00_Main_GridView_lieutenants开头的所有span

//a[span[starts-with(@id, 'ctl00_Main_GridView_lieutenants')]]/@href

选择所有a 中的@href,其中有子span,其中@idctl00_Main_GridView_lieutenants 开头

【讨论】:

    猜你喜欢
    • 2012-01-07
    • 1970-01-01
    • 2011-04-20
    • 2020-01-17
    • 2011-11-25
    • 1970-01-01
    • 2013-02-13
    • 2018-06-13
    • 1970-01-01
    相关资源
    最近更新 更多