1

我想匹配这样的链接<a href="mailto:my@email.com">foo</a>,但这仅适用于 Nokogiri:

doc/'a[href ^="mailto:"]'

这样做的正确方法是什么?我如何使用 Hpricot 做到这一点?

4

2 回答 2

3
doc/"//a[starts-with(@href,'mailto')]"
于 2009-11-03T01:15:43.387 回答
0

这适用于 Hpricot:

doc/'a[@href ^="mailto:"]'

虽然无法找到进行 xpath 搜索的方法。显然,Hpricot 不支持starts-withhttp ://wiki.github.com/hpricot/hpricot/supported-xpath-expressions

于 2009-11-03T03:15:15.860 回答