note 116879 deleted from domelement.construct by sobak

From: Date: Sun, 15 Mar 2015 05:01:17 +0000
Subject: note 116879 deleted from domelement.construct by sobak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-201946@lists.php.net to get a copy of this message
Note Submitter: RiKdnUA at mail dot ru ---- В русской версии описания DOMElement::__construct() ошибка. Должно быть: ...Этот объект доступен только для чтения. Он может быть добавлен в документ, но в него нельзя добавить дочерние узлы пока данный узел НЕ связан с документом... В английской версии описания все правильно: ...This object is read only. It may be appended to a document, but additional nodes may not be appended to this node until the node is associated with a document... <?php error_reporting(-1); $dom = new DOMDocument('1.0', 'iso-8859-1'); $element = $dom->appendChild(new DOMElement('root')); $element_ns = new DOMElement('pr:node1', 'thisvalue', 'http://xyz'); $element->appendChild($element_ns); $second=new DOMElement('second'); //$second->appendChild(new domText('secondText'));//Fatal error: Uncaught exception 'DOMException' with message 'No Modification Allowed Error' $element_ns->appendChild($second); $second->appendChild(new domText('secondText'));//Okay. Not error $dom->formatOutput=true; echo "Bytes recorded: ".$dom->save('file.xml'); ?>

« previous php.notes (#201946) next »