saveHTMLFile generates empty files
| From: | Bernhard Zwischenbrugger | Date: | Fri, 05 Nov 2004 09:16:07 +0000 |
| Subject: | saveHTMLFile generates empty files | ||
| Groups: | php.xml.dev | ||
| Request: | Send a blank email to php-xml-dev+get-497@lists.php.net to get a copy of this message | ||
Hi all
I have problems with non ascii characters.
There is no problem if the client sends UTF-8 encoded strings.
But I don't own all clients ;-)
Is there a possibility to check errors before I save the File?
In the examle I try to change a HTML file. If you give öäü (German Umlauts)
as GET Parameter
the html File is destroyed. The saveHTMLFile gives a warning but that's too
late.
There is an other problem with the save method.
If the Harddisk is full, the save method converts to a delete method ;-)
Bernhard
test.html:
==========
<html>
<body>
</body>
</html>
php program:
============
<?php
$dom=domDocument::loadHTMLFile('test.html');
$body=$dom->getElementsByTagName("body")->item(0);
$textnode=$dom->createTextNode($_GET['umlaut']); //try öäü
$body->appendChild($textnode);
print $dom->saveHTML();
//save changed html file
//if(file is ok and has no iconv errors){ <-- how to do that?
$dom->saveHTMLFile('test.html')
//}
?>