Help help please help

i have written a slighly bastardized version of the class web page
which is given as an example of how to use the html tokenizer.

What I've written is:

   def parse(host)
   dict = { }
   @body= host.getHTML()
   if !@body
    return
   end
     theTags = ['select','input']
        for x in theTags do
          tokenizer = HTMLTokenizer.new(@body)
             while tag = tokenizer.getTag(x)
               name = tag.attr_hash['name']
               type = tag.attr_hash['type']
                if name != nil then
                 dict[type]=name
                end # if
             end# while
       end# for x
    return dict
   end # end parse

My problem is that parse will return all tag attributes of "type" (ie
"checkbox, "button", "hidden") except for those which are of type
"text". I haven't been able to figure out where I'm going wrong.

Beth

Have you made sure your text input tags have a name attribute?

require 'html/htmltokenizer'

host = Object.new
def host.getHTML
  html = <<EOT
  <form>
    <input name="txt1" type="text" value="test" />
    <input name="pwd1" type="password" value="test" />
    <input name="ck1" type="checkbox" value="1" checked="true"/>
  </form>
EOT
end

# Your code follows unchanged

  def parse(host)
  dict = { }
  @body= host.getHTML()
  if !@body
   return
  end
    theTags = ['select','input']
       for x in theTags do
         tokenizer = HTMLTokenizer.new(@body)
            while tag = tokenizer.getTag(x)
              name = tag.attr_hash['name']
              type = tag.attr_hash['type']
               if name != nil then
                dict[type]=name
               end # if
            end# while
      end# for x
   return dict
  end # end parse

p parse(host)

-- Output --
{"text"=>"txt1", "checkbox"=>"ck1", "password"=>"pwd1"}

Regards,

Sean