Ticket #59 (assigned enhancement)
Support XPaths with predicate expressions
| Reported by: | ecmanaut | Owned by: | why |
|---|---|---|---|
| Priority: | major | Milestone: | |
| Component: | ext/hpricot_scan | Version: | |
| Keywords: | Cc: |
Description
When singling out nodes, it is often useful to be able to point at some node along the path, using a basic transform along the lines of this. The latter two expressions are different ways of phrasing the same thing, but the shorter version does not work:
doc.search('//tr/td/a[@href^="diary_read"]').length # => 20 (is correct)
doc.search('//tr[td/a[@href^="diary_read"]]').length # => 561 (want 20!)
doc.search('//tr/td/a[@href^="diary_read"]/../..').length # => 20 (okay)
I'd love to have all three render the same amount of nodes so I won't have to translate my XPath thoughts into HpricotPath? quite so often. There wouldn't happen to be any chances of metaprogramming up something cool that would let a real XPath engine explore Hpricot's inner state to run queries against it, using W3C style XPath, barfing on everything else?
