From: Jeremy Milarsky Date: 2007-12-25T03:28:01+09:00 Subject: Re: Double slash in Hpricot...? A follow-up question: "/" is supposed to be synonymous with Hpricot::Elem#search ... is "//" as well? Phlip wrote: > Daniel Waite wrote: > >> What's the purpose of the double slash in Hpricot? >> >> doc.search("/html/body//p") > > Google for an XPath tutorial. // is XPathic for the "any descendant" > axis. > So the above matches any

(presumably the first) in the body of a > document. > > The equivalent in XPath would be assert_xpath('/html/body//p'). I don't > know > how close Hpricot comes to XPath, which can do things like this: > > assert_xpath ".//Statement[ last() - 1 ]" > > > That matches the second-to-last item called > > However, REXML::XPath cannot handle common XHTML idioms... > > Can't we all just ... get along? -- Posted via http://www.ruby-forum.com/.