# Hpricot problem

**URL:** <https://www.ruby-forum.com/t/hpricot-problem/150691>\
**Category:** Rails\
**Created:** [October 11, 2008, 4:45pm UTC](https://www.ruby-forum.com/t/hpricot-problem/150691 "2008-10-11T16:45:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jef](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e5b9ba/32.png) [@jef](https://www.ruby-forum.com/u/jef)\
**Post date:** [October 11, 2008, 4:45pm UTC](https://www.ruby-forum.com/t/hpricot-problem/150691/1 "2008-10-11T16:45:51Z")

</div>

Hi,

I would like to know how to retrieve the value of an attribute.

For example (doc/".nom/a") will return an array of elements. I would  
like to know the value of the href attribut of each element.

thanks for your help

---

<div class="post-metadata">

**Author:** ![jef](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e5b9ba/32.png) [@jef](https://www.ruby-forum.com/u/jef)\
**Post date:** [October 12, 2008, 5:19am UTC](https://www.ruby-forum.com/t/hpricot-problem/150691/2 "2008-10-12T05:19:16Z")

</div>

elems = doc.search("//a")  
elems.each do |elem|  
p elem.get\_attribute(“href”)  
end
