Validation, meet Unit Testing. Unit Testing, meet Validation.
[cross posted from the "WaSP":http://webstandards.org/buzz/archive/2005_09.html#a000577 to take comments]
Are you "test infected":http://www.extremeprogramming.org/rules/unittests.html? Do you work on dynamic sites and wish there was an automated way to run the output through the "W3C validator":http://validator.w3.org/? Do you wish it was integrated nicely with your unit testing framework?
Scott Raymond has come up with "a nice bit of code":http://scottraymond.net/articles/2005/09/20/rails-xhtml-validation to add automated validation to the unit tests for a "Ruby on Rails":http://www.rubyonrails.org/ application.
If you're not on Rails, the technique should be pretty straightforward to adapt to your prefered language/framework. Just make a <code>POST</code> request to <code>http://validator.w3.org/check</code> sending parameters <code>fragment</code> (your page, encoded) and <code>output=xml</code>. Then check the response for a header called <code>x-w3c-validator-status</code> to see if it says <code>Valid</code>. If so, your test passed.