# Re: using Xpath in Ruby

**URL:** <https://www.ruby-forum.com/t/re-using-xpath-in-ruby/138016>\
**Category:** Ruby\
**Created:** [May 19, 2008, 3:08pm UTC](https://www.ruby-forum.com/t/re-using-xpath-in-ruby/138016 "2008-05-19T15:08:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![McLaughlinS\_James\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f04885/32.png) [@McLaughlinS\_James\_T](https://www.ruby-forum.com/u/McLaughlinS_James_T)\
**Post date:** [May 19, 2008, 3:08pm UTC](https://www.ruby-forum.com/t/re-using-xpath-in-ruby/138016/1 "2008-05-19T15:08:07Z")

</div>

I use hpricot for all my XML - to access a node in a doc via XPath, you  
just do:

node = (doc / “/path/to/node”)

The / operator is overloaded to do XPath. Check out the docs first (use  
google) for the exact syntax. You must explicitly tell hpricot you are  
parsing xml or it will not work right.

Jamie McLaughlin  
SAIC  
Office: 703-292-6307  
Mobile: 571-263-2528

----- Original Message -----  
From: removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: ruby-talk ML [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Mon May 19 06:40:32 2008  
Subject: using Xpath in Ruby

Dear friends,

I want use xpath in my ruby program. could you please suggest some ways  
to proceed .?. Some links would help me to do…

I need some some details regarding how its implemented in REXML and  
HPRICOT.

Thanks in advance…

## Regards, Jose

Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
