If you write test you must create an expected result exactly (character by character) as it will be generated. Mostly I only want to know if the html-structure is good.
It's much more convenient to write the expected structure with newlines and indention, than writing everything into one single line with blanks in it.
So I would prefer to have the possibility to pretty-print the result and the expected result. This can be done with XMLPretty-Printing or more less accurate with JTidy.
Another approach would be to compare the DOM-Tree directly.
Third solution: Take the expected result and remove all unused Whitespaces.