[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Hpricot question

Dan Diebolt

7/13/2008 4:44:00 AM

[Note: parts of this message were removed to make it a legal post.]

>What I need, however is a method that tells me the first HTML tag of a fragment, whatever it is

Try this:

a_fragment = '<div id="my_first_div">first div<p>a paragraph</p><span>a span</span></div>'

doc=Hpricot(a_fragment)

tag=doc.search("[1]").first.name

=> "div"



1 Answer

Rainer

7/13/2008 9:21:00 PM

0

Thank you Ömer,
Thank you Dan,

that did the trick. However, I couldn't find anything about
Hpricot::Elem in the official rdoc:

http://code.whytheluckystiff.net/do...

After you told me about it, I could find the helpful "name" method
with

puts doc.search("[1]").first.methods.sort

Ömer and Dan, how did you find out about the methods of Hpricot::Elem
and "name", in particular?

Kind regards,

Rainer