note 60042 added to function.dom-domdocument-normalize
| From: | kencomer at kencomer dot com | Date: | Fri, 23 Dec 2005 19:23:03 +0000 |
| Subject: | note 60042 added to function.dom-domdocument-normalize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-100634@lists.php.net to get a copy of this message | ||
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>
----
Manual Page -- http://www.php.net/manual/en/function.dom-domdocument-normalize.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+60042
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60042&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60042&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60042&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60042&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60042&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60042&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60042&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+60042&report=yes
Search -- http://master.php.net/manage/user-notes.php