dom005.phpt 986 B

123456789101112131415161718192021222324252627282930313233
  1. --TEST--
  2. Test 5: HTML Test
  3. --EXTENSIONS--
  4. dom
  5. --FILE--
  6. <?php
  7. $dom = new domdocument;
  8. $dom->loadHTMLFile(__DIR__."/test.html", LIBXML_NOBLANKS);
  9. print "--- save as XML\n";
  10. print adjustDoctype($dom->saveXML());
  11. print "--- save as HTML\n";
  12. print adjustDoctype($dom->saveHTML());
  13. function adjustDoctype($xml) {
  14. return str_replace(array("DOCTYPE HTML",'<p>','</p>'),array("DOCTYPE html",'',''),$xml);
  15. }
  16. ?>
  17. --EXPECT--
  18. --- save as XML
  19. <?xml version="1.0" standalone="yes"?>
  20. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
  21. <html><head><title>Hello world</title></head><body>
  22. This is a not well-formed<br/>
  23. html files with undeclared entities&#xA0;
  24. </body></html>
  25. --- save as HTML
  26. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
  27. <html><head><title>Hello world</title></head><body>
  28. This is a not well-formed<br>
  29. html files with undeclared entities&nbsp;
  30. </body></html>