Q:

How do I get the tag name and CSS classes from Nokogiri::HTML

I've been trying to parse these HTML files with Nokogiri.  This is the code I was using
require 'nokogiri'
doc = Nokogiri::HTML File.open('usc...html', 'r')
children = doc.css('body div')
children.each do |child|
    puts child.name
end

That prints div for all of the child elements even though they are almost entire p, h3 and h4 tags.  Can someone explain why that is happening?  Also, how do I get the CSS classes off of them? 

A:

This:
doc.css('body div')

Will select every div on the page.  If you want every element you should use:
doc.css('*')

You can get at the css class with child[:class]

