Posted By

noah on 06/04/09


Tagged

ruby xml Gem Hpricot


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

webstic


parse an xml file with hpricot and Ruby


 / Published in: Ruby
 

URL: http://localhost:8808/doc_root/hpricot-0.6/rdoc/index.html oneliner

Say gem server if the above URL doesn't work for you

  1. doc = open("file.xml") { |f| Hpricot.XML(f) }
  2.  
  3. # examples assuming RSS from a Yahoo! Pipe
  4.  
  5. items = doc.search "ul.htmlresults > li"
  6.  
  7. links = items.search "a"
  8.  
  9. images = items.search "img"

Report this snippet  

You need to login to post a comment.