note 116879 deleted from domelement.construct by sobak
| From: | sobak@php.net | 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');
?>