Looks like REXML does not parse HTML:
doc = REXML::Document.new("<form><input type='text' name='name'></form>")
/usr/local/bundle/gems/rexml-3.3.6/lib/rexml/parsers/baseparser.rb:446:in `pull_event': Missing end tag for 'input' (got 'form') (REXML::ParseException)