xref: /PHP-7.3/ext/dom/tests/dom005.phpt (revision b746e698)
1--TEST--
2Test 5: HTML Test
3--SKIPIF--
4<?php  require_once('skipif.inc'); ?>
5--FILE--
6<?php
7$dom = new domdocument;
8$dom->loadHTMLFile(dirname(__FILE__)."/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--EXPECT--
20--- save as XML
21<?xml version="1.0" standalone="yes"?>
22<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
23<html><head><title>Hello world</title></head><body>
24This is a not well-formed<br/>
25html files with undeclared entities&#xA0;
26</body></html>
27--- save as HTML
28<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
29<html><head><title>Hello world</title></head><body>
30This is a not well-formed<br>
31html files with undeclared entities&nbsp;
32</body></html>
33