# Double slash in Hpricot...?

**URL:** <https://www.ruby-forum.com/t/double-slash-in-hpricot/109457>\
**Category:** Ruby\
**Created:** [July 15, 2007, 6:10am UTC](https://www.ruby-forum.com/t/double-slash-in-hpricot/109457 "2007-07-15T06:10:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dewie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dewie](https://www.ruby-forum.com/u/dewie)\
**Post date:** [July 15, 2007, 6:10am UTC](https://www.ruby-forum.com/t/double-slash-in-hpricot/109457/1 "2007-07-15T06:10:26Z")

</div>

What’s the purpose of the double slash in Hpricot?

doc.search("/html/body//p")

---

<div class="post-metadata">

**Author:** ![dewie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dewie](https://www.ruby-forum.com/u/dewie)\
**Post date:** [July 15, 2007, 7:31am UTC](https://www.ruby-forum.com/t/double-slash-in-hpricot/109457/2 "2007-07-15T07:31:04Z")

</div>

Daniel W. 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?

---

<div class="post-metadata">

**Author:** ![dewie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dewie](https://www.ruby-forum.com/u/dewie)\
**Post date:** [December 24, 2007, 7:28pm UTC](https://www.ruby-forum.com/t/double-slash-in-hpricot/109457/3 "2007-12-24T19:28:06Z")

</div>

A follow-up question:

“/” is supposed to be synonymous with Hpricot::Elem#search … is “//”  
as well?

Phlip wrote:

> Daniel W. 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?
