views:

255

answers:

2

I want to match links like <a href="mailto:[email protected]">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?

+2  A: 
doc/"//a[starts-with(@href,'mailto')]"
glenn mcdonald
I tried that, also didn't work. Then I switched to Nokogiri and both examples worked. I thought they had similar APIs. Doesn't Hpricot also support css-selector/xpath searches? Do you know how to do the same in Hpricot?
obvio171
A: 

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

obvio171