From: Chad Fowler Date: 2003-10-13T09:21:23+09:00 Subject: Re: XPath and HTML On Mon, 13 Oct 2003, David Corbin wrote: # On Sunday 12 October 2003 17:36, Chad Fowler wrote: # > On Mon, 13 Oct 2003, David Corbin wrote: # > # > # Is there a library out there that let's me parse HTML and use XPath # > # expressions against it? What is it? # > # # > # Thanks # > # # > # # > # > REXML (http://www.germane-software.com/software/rexml/) and # > HTML Parser2 (http://www.bike-nomad.com/ruby/) # > # # Are you saying you parse it with HTML Parser2, and then use the XPath support # out of the REXML? # Sort of. I shouldn't have said "HTML Parser2". The right name seems to be ruby-htmltools. It integrates with REXML and allows you to do this: parser = HTMLTree::Parser.new(true, true) parser.feed(file.readlines.join) tree = parser.tree.html_node.as_rexml_document tree.elements.to_a('*/table').each do |element| # do something with element end Chad