On Tue, Jun 22, 2010 at 7:57 AM, Tasos Laskos <zapotek / segfault.gr> wrote:

> But I'm stumped with Nokogiri's API.
>
> I can't figure anything out, I don't know what are the available methods
> or attributes of a doc object, can't figure out how to get html "type",
> "name" and "value" fields.

Using irb to explore might help, e.g.
   doc =  something something
   doc.methods

But since you're apparently interested in form fields -- and to me, the
doc is pretty obvious about this -- take a trivial example where 'doc'
is a page with a form in it:

>> inputs = doc.search('//input')
=> [#<Nokogiri::XML::Element:0x80de9c04 name="input"
attributes=[#<Nokogiri::XML::Attr:0x80de9ab0 name="type"
value="text">, #<Nokogiri::XML::Attr:0x80de9a9c name="name"
value="hsTotal">, #<Nokogiri::XML::Attr:0x80de9a88 name="id"
value="hsTotal">]>]
>> inputs[0]
=> #<Nokogiri::XML::Element:0x80de9c04 name="input"
attributes=[#<Nokogiri::XML::Attr:0x80de9ab0 name="type"
value="text">, #<Nokogiri::XML::Attr:0x80de9a9c name="name"
value="hsTotal">, #<Nokogiri::XML::Attr:0x80de9a88 name="id"
value="hsTotal">]>

By just looking at the above, I see this object has "attributes", so

>> inputs[0].attributes['type'].to_s
=> "text"
>> inputs[0].attributes['name'].to_s
=> "hsTotal"

And so on...

HTH!
-- 
Hassan Schroeder ------------------------ hassan.schroeder / gmail.com
twitter: @hassan