# A Little Help with Hpricot Parsing

**URL:** <https://www.ruby-forum.com/t/a-little-help-with-hpricot-parsing/137073>\
**Category:** Rails\
**Created:** [May 8, 2008, 6:52pm UTC](https://www.ruby-forum.com/t/a-little-help-with-hpricot-parsing/137073 "2008-05-08T18:52:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![karlshea](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/58956e/32.png) [@karlshea](https://www.ruby-forum.com/u/karlshea)\
**Post date:** [May 8, 2008, 6:52pm UTC](https://www.ruby-forum.com/t/a-little-help-with-hpricot-parsing/137073/1 "2008-05-08T18:52:50Z")

</div>

I need to scrape out the name, address, city, state, zip, etc. from  
site. Due to their wonderful coding, they didn’t put lines of text in

tags. So Hpricot doesn't see the address (et al) as an element, but it does see the   
 as empty elements.

So how do I pick out the address and so forth if they are not in  
elements?

Here is what I have scraped so for, down to my target table:

| 
### Bank of America
 405 N. 3rd Street  
 Phoenix, Arizona&nbsp;60606  
 Distance: N/A  
 800-555-1212  

- **June 15 - 20 2008**  
 6:00 PM&nbsp;-&nbsp;9:00 PM  
 Event Theme Name  

* * *

### Washington Mutual
 3705 Beaver Creek Rd  
 Austin, Texas&nbsp;60606  
 Distance: N/A  
 800-555-1212  

- **July 07 - 11 2008**  
 9:00 AM&nbsp;-&nbsp;12:00 AM  
 Event Theme Name  

* * *
 |

---

<div class="post-metadata">

**Author:** ![karlshea](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/58956e/32.png) [@karlshea](https://www.ruby-forum.com/u/karlshea)\
**Post date:** [May 9, 2008, 12:17am UTC](https://www.ruby-forum.com/t/a-little-help-with-hpricot-parsing/137073/2 "2008-05-09T00:17:10Z")

</div>

> So how do I pick out the address and so forth if they are not in  
> elements?

Use that fact to your advantage. The only non-elements in the table  
cell are your addresses.

doc.search(’/table/tr/td/\*’).each do |node|  
print node unless node.elem?  
end

This will print out the addresses only.
