# HTML parser using Hpricot

**URL:** <https://www.ruby-forum.com/t/html-parser-using-hpricot/181267>\
**Category:** Ruby\
**Created:** [January 8, 2010, 3:32pm UTC](https://www.ruby-forum.com/t/html-parser-using-hpricot/181267 "2010-01-08T15:32:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![robert-ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c4cdca/32.png) [@robert-ruby](https://www.ruby-forum.com/u/robert-ruby)\
**Post date:** [January 8, 2010, 3:32pm UTC](https://www.ruby-forum.com/t/html-parser-using-hpricot/181267/1 "2010-01-08T15:32:34Z")

</div>

Hello folks,

I am a newbie to RoR and writing an HTML parser using Hpricot. I can  
parse a html file with:  
(1) doc = open( “MyFileToParse.html” ) { |f| Hpricot(f) }  
(2) elements = (doc.search(“/html/body/table/tr/td/table/tr/td/font”) )  
(3) puts (elements[13]).inner\_html

to get the following output:

Giaever G, et al (2002). Functional profiling of the Saccharomyces c  
erevisiae genome. Nature, 418:387-91. [[PubMed](http://www.ncbi.nlm.nih.gov/entr%0Aez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=12140549&dopt=Abstract)]

How can I proceed to get the following results (3) and (4) respectively?  
(3) Giaever G, et al (2002). Functional profiling of the Saccharomyces c  
erevisiae genome. Nature, 418:387-91.

(4) [http://www.ncbi.nlm.nih.gov/pubmed/12140549?dopt=Abstract](http://www.ncbi.nlm.nih.gov/pubmed/12140549?dopt=Abstract)

NOTE: to get (4) I need to take two more steps: (5) replace “&” with “?”  
(6) replace “PubMed” with “pubmed” (this might be trivial, but how?) in  
the process of parsing in addition to “normal” HTML parsing.

Thanks a lot in advance.  
Robert
