# Finding elements with hpricot/nokogiri

**URL:** <https://www.ruby-forum.com/t/finding-elements-with-hpricot-nokogiri/175829>\
**Category:** Rails\
**Created:** [September 21, 2009, 2:47am UTC](https://www.ruby-forum.com/t/finding-elements-with-hpricot-nokogiri/175829 "2009-09-21T02:47:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [September 21, 2009, 2:47am UTC](https://www.ruby-forum.com/t/finding-elements-with-hpricot-nokogiri/175829/1 "2009-09-21T02:47:54Z")

</div>

I am attempting to parse a wiktionary entry to retrieve all english  
definitions. I am able to retrive all definitions, the problem is  
that some definitions are in other languages. What I would like to do  
is somehow retrieve only the html block with english definitions. I  
have found that, in the case that there are other language entries,  
the header after the english definitions can be retrieved with: header  
= (doc/“h2”)[3]. So I would like to only search all the elements  
before this header element. I thought that may be possible with  
header.preceding\_siblings(), but that does not seem to be working.  
Any suggestions?

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [September 23, 2009, 2:58am UTC](https://www.ruby-forum.com/t/finding-elements-with-hpricot-nokogiri/175829/2 "2009-09-23T02:58:41Z")

</div>

Just in case anyone runs into this: I created my own recursive  
function that starts at the end element and checks each previous  
element and adds it to an array for a match.
