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