Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.80
diff -u -r1.80 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	19 Jan 2009 10:46:51 -0000	1.80
+++ modules/simpletest/drupal_web_test_case.php	20 Jan 2009 08:47:09 -0000
@@ -1030,12 +1030,14 @@
     if (!$this->elements) {
       // DOM can load HTML soup. But, HTML soup can throw warnings, suppress
       // them.
-      @$htmlDom = DOMDocument::loadHTML($this->content);
-      if ($htmlDom) {
-        $this->pass(t('Valid HTML found on "@path"', array('@path' => $this->getUrl())), t('Browser'));
+      $dom = new DOMDocument();
+//      $dom->validateOnParse = TRUE;
+      $dom->loadHTML($this->content);
+      if ($dom) {
+//        $this->assertTrue($htmlDom->validate(), t('Page source (@path) is valid.', array('@path' => $this->getUrl())), t('Browser'));
         // It's much easier to work with simplexml than DOM, luckily enough
         // we can just simply import our DOM tree.
-        $this->elements = simplexml_import_dom($htmlDom);
+        $this->elements = simplexml_import_dom($dom);
       }
     }
     if (!$this->elements) {
Index: test.php
===================================================================
RCS file: test.php
diff -N test.php
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ test.php	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,57 @@
+<?php
+//$contents = file_get_contents('test.html');
+
+$dom = new DOMDocument();
+$dom->validateOnParse = TRUE;
+//var_dump($dom->loadHTMLFile('test.html'));
+var_dump($dom->load('test.html', LIBXML_DTDLOAD|LIBXML_DTDVALID)); // LIBXML_DTDLOAD|LIBXML_DTDATTR
+//var_dump($dom->loadHTML($contents));
+var_dump($dom->validate());
+
+class MyDOMDocument {
+    private $_delegate;
+    private $_validationErrors;
+   
+    public function __construct (DOMDocument $pDocument) {
+        $this->_delegate = $pDocument;
+        $this->_validationErrors = array();
+    }
+   
+    public function __call ($pMethodName, $pArgs) {
+        if ($pMethodName == "validate") {
+            $eh = set_error_handler(array($this, "onValidateError"));
+            $rv = $this->_delegate->validate();
+            if ($eh) {
+                set_error_handler($eh);
+            }
+            return $rv;
+        }
+        else {
+            return call_user_func_array(array($this->_delegate, $pMethodName), $pArgs);
+        }
+    }
+    public function __get ($pMemberName) {
+        if ($pMemberName == "errors") {
+            return $this->_validationErrors;
+        }
+        else {
+            return $this->_delegate->$pMemberName;
+        }
+    }
+    public function __set ($pMemberName, $pValue) {
+        $this->_delegate->$pMemberName = $pValue;
+    }
+    public function onValidateError ($pNo, $pString, $pFile = null, $pLine = null, $pContext = null) {
+        $this->_validationErrors[] = preg_replace("/^.+: */", "", $pString);
+    }
+}
+
+// $doc is a DOMDocument object
+//$myDoc = new MyDOMDocument($doc); // copy constructor
+//
+//// do anything with $myDoc that you would with $doc
+//
+//$isValid = $myDoc->validate(); // won't create warnings
+//if (!$isValid) {
+//    print_r($myDoc->errors); // the array all warnings are collected in
+//}
Index: test.html
===================================================================
RCS file: test.html
diff -N test.html
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ test.html	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,12 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
+  "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
+<html dir="ltr">
+  <head>
+    <title>drupal-7.dev.loc</title>
+  </head>
+  <body>
+  <div>
+  hax
+  </div>
+  </body>
+</html>
