note 76218 added to function.dom-domdocument-createelement
| From: | poison at osu1 dot php dot net | Date: | Thu, 05 Jul 2007 17:11:58 +0000 |
| Subject: | note 76218 added to function.dom-domdocument-createelement | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128252@lists.php.net to get a copy of this message | ||
In response to 'mikek dot nospam at nospam dot muonics dot com', here is a more correct
version, as values have to be UTF-8 encoded, and there's absolutely no reason to create an
extra DOMElement class.
<?php
class ADOMDocument extends DOMDocument {
function __construct($version = null, $encoding = null) {
parent::__construct($version, $encoding);
}
public function createElement($tagName, $value=null) {
$node=parent::createElement($tagName);
if (!is_null($value)) {
$node->appendChild(
$this->createTextNode(utf8_encode($value))
);
}
return $node;
}
public function createElementNS($namespaceURI, $qualifiedName, $value=null) {
$node=parent::createElementNS($namespaceURI, $qualifiedName);
if (!is_null($value)) {
$node->appendChild(
$this->createTextNode(utf8_encode($value))
);
}
return $node;
}
}
?>
----
Server IP: 64.71.164.2
Probable Submitter: 217.28.97.3 (proxied: 192.10.10.76)
----
Manual Page -- http://www.php.net/manual/en/function.dom-domdocument-createelement.php
Edit -- https://master.php.net/note/edit/76218
Del: integrated -- https://master.php.net/note/delete/76218/integrated
Del: useless -- https://master.php.net/note/delete/76218/useless
Del: bad code -- https://master.php.net/note/delete/76218/bad+code
Del: spam -- https://master.php.net/note/delete/76218/spam
Del: non-english -- https://master.php.net/note/delete/76218/non-english
Del: in docs -- https://master.php.net/note/delete/76218/in+docs
Del: other reasons-- https://master.php.net/note/delete/76218
Reject -- https://master.php.net/note/reject/76218
Search -- https://master.php.net/manage/user-notes.php