From: Li Chen Date: 2008-08-11T21:59:03+09:00 Subject: Re: Hpricot and path of an elememt David Masover wrote: > Now, first question: Why do you need the xpath? Usually, the idea is to > try to > find that element, and then do something with it. So, for example: > # To return all text: > (doc / 'font').text > > # To loop over each font element: > (doc / 'font').each { |tag| > puts tag.inner_text > } I need to extract text within this tag. I follow you code and I find 1) (doc/'font').text and (doc/'font').html return the same results 2) when I run (doc / 'font').each { |tag| puts tag.inner_text} Ruby complains it: undefined method `inner_text' for # (NoMethodError) so I change it to tag.inner_html and it works. I check the document about hpricot and find the methode #inner_text is there. But I cannot figure out why Ruby complains about it. > Second question: Why is there a font tag on this page? If you had any > hand in > creating the page, shame on you -- go learn some CSS. I am a newbie on HTML and website development. If you want to know why there is a font tag in the page, please check this out: http://www.ensembl.org/Homo_sapiens/exonview?db=core;transcript=ENST00000356766 What I try to do is to extract some info I am interested from this page. I have no idea why they put this tag and that tag there. I don't think it is my priority to know somany whys now. I am more concerned about letting the job done. Anyway thank very much for the tips. Li -- Posted via http://www.ruby-forum.com/.