From: Peter Szinek Date: 2006-12-18T01:55:26+09:00 Subject: Re: hpricot problem > I have found that saved pages from Firefox are different then the html > hpricot uses. Of course they are. If you save a page from Firefox, (or IE, or just any browser) the page gets saved as-it-is (i.e. as the author put it on the web server - with all the errors, non-conforming, unclosed or otherwise malformed tags, etc.) Now, what happens when a browser renders the page? It builds a Document Object Model (DOM) out of the HTML and renders the DOM. This DOM conforms to strict rules (i.e. no wild-wild-west HTML crapfest). If you would dump it to a file as an XML, you would have a correct XHTML page, which would resemble to the original HTML as much as the browser's DOM building rules make this possible (generally very close to standards in the case of Mozilla and Opera, crappy in the case of IE (at least before 6, I am not sure about 7)). What Hpricot does is very similar: It builds a DOM of the HTML. (I am not sure if _why calls this a DOM or whatever, but it is an internal representation of the underlying HTML). Of course Mozilla DOM != HPricot DOM (!= IE DOM != Opera DOM et cetera) therefore you can't make assumptions about what does Hpricot do based on what does Mozilla do. If you want Mozilla to parse your page and return the DOM (or serialize it to XML so you can feed it to an XML/XSLT/XPath engine), I can show you how, but only in Java - unfortunately Ruby's tools are not yet there. Or, you can use Hpricot and forget about how it works in everywhere else... Cheers Peter __ http://www.rubyrailways.com