note 60042 deleted from function.dom-domdocument-normalize by bjori
| From: | bjori@php.net | Date: | Mon, 24 Apr 2006 21:08:42 +0000 |
| Subject: | note 60042 deleted from function.dom-domdocument-normalize by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-109611@lists.php.net to get a copy of this message | ||
Note Submitter: kencomer at kencomer dot com
----
You can load the web page below, changing the value of XML_FILE and contrast the original and
normalized versions of a file.
<?php
/**
* contrast normalized DOM
*
* simple routine that allows easy comparison between normalized XML and
* the original file, also showing basic usage of simplexml object.
* @author Ken Comer <kencomer@kencomer.com>
* @copyright Copyright © 2005 Ken Comer, released under GNU Free Documentation License
* (see http://www.gnu.org/copyleft/fdl.html#TOC1 for
more information)
*/
define("PAGE_TITLE","compare simplexml, dom, and normalized versions");
define('XML_FILE','simplified.xml');
?>
<!doctype html public "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<link rel="stylesheet" type="text/css" href="default.css" />
<style>
</style>
<html>
<head>
<!-- meta information -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name=author content="Ken Comer">
<meta http-equiv="keywords" content="" />
<title><?php PAGE_TITLE ?></title>
</head>
<body>
<pre><?php
if ( $handle = fopen(XML_FILE,'r') ) {
$data = '';
while ( !feof($handle) ) {
$data .= fread( $handle, 8192 );
}
fclose($handle);
print("<h1>Input File
'".XML_FILE."'</h1><pre>\n".htmlentities($data).'</pre>');
} else die("error opening input file.\n");
$sXmlTest = simpleXML_load_file( XML_FILE );
print("<h1>Simple XML
asXML:</h1><pre>\n".htmlentities($sXmlTest->asXML()).'</pre>');
$domTest = DOMdocument::loadXML( $data );
print(
"<h1>Simple XML import DOM:</h1><pre>\n"
.htmlentities(simplexml_import_dom($domTest)->asXML()).'</pre>')
;
$domTest->normalize();
print(
"<h1>Simple XML import normalized DOM:</h1><pre>\n"
.htmlentities($domTest->saveXML())
.'</pre>')
;
?>
</pre>
</body>
</html>