Searching Hpricot With XPath
Part of AnHpricotShowcase.
Before starting this section, you are encouraged to read HpricotCssSearch. The CSS selectors are almost always easier to write and cleaner to combine. In addition, XPath support is pretty limited at present.
Using XPath Expressions
When calling the search or the slash / methods, you may use XPath expressions as the search string.
#!ruby
doc = Hpricot(URI.parse("http://we-make-money-not-art.com/").read)
(doc/'//div/img')
#=> Elements[...]
For a complete list of expressions, see SupportedXpathExpressions.
