开发者

How to detect mailto links with Hpricot/Nokogiri

开发者 https://www.devze.com 2022-12-09 22:02 出处:网络
I want to match link开发者_Go百科s like <a href=\"mailto:my@email.com\">foo</a>, but this doesn\'t work only works in Nokogiri:

I want to match link开发者_Go百科s like <a href="mailto:my@email.com">foo</a>, but this doesn't work only works in Nokogiri:

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

What's the right way of doing that? How do I do that with Hpricot?


doc/"//a[starts-with(@href,'mailto')]"


This works on Hpricot:

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

Couldn't figure out a way to do the xpath search though. Apparently, Hpricot doesn't support starts-with: http://wiki.github.com/hpricot/hpricot/supported-xpath-expressions

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号