note 30269 added to function.domnode-dump-node
| From: | php-general at lists dot php dot net | Date: | Wed, 12 Mar 2003 17:47:13 +0000 |
| Subject: | note 30269 added to function.domnode-dump-node | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-45161@lists.php.net to get a copy of this message | ||
The note above is exact :
dump_node is not a method of the DomNode class anymore but a method of DomDocument class.
Note that "$dom->dump_node($myNodeObject); " also works in PHP 4.2.
So I recommand to use it like this.
Last thing : you can't specified the encoding in the dump_node methode contrary to the dump_mem
method.
So characters like 'é' are always converted in UTF-8.
The function below does exactly the same work as dump_node but also take in argument the encoding :
(it's not elegant but it works)
function my_dump_node($node,$encoding){
$domNode = domxml_new_doc("1.0");
$clonedNode = $node->clone_node(true);
$domNode->append_child($clonedNode);
$result = $domNode->dump_mem(true,$encoding);
$pos = strpos($result,"?>");
return substr($result,$pos+2);
}
so
$dom->dump_node($myNodeObject);
becomes
my_dump_node($myNodeObject,"ISO-8859-1");
--
http://www.php.net/manual/en/function.domnode-dump-node.php
http://master.php.net/manage/user-notes.php?action=edit+30269
http://master.php.net/manage/user-notes.php?action=delete+30269
http://master.php.net/manage/user-notes.php?action=reject+30269