mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Fixed bug #53083 (DOMNode::removeChild() resets the namespaceURI value)
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@304621 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
cec7396039
commit
29ab385baf
1 changed files with 37 additions and 0 deletions
|
@ -97,6 +97,43 @@ echo $doc->saveXML();
|
|||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>Preserving the parent node's namespace URI</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$doc = new DOMDocument;
|
||||
$doc->load('book.xml');
|
||||
|
||||
$book = $doc->documentElement;
|
||||
|
||||
// we retrieve the chapter and remove it from the book
|
||||
$chapter = $book->getElementsByTagName('chapter')->item(0);
|
||||
|
||||
// copy the namespace URI
|
||||
$nsuri = $book->namespaceURI;
|
||||
|
||||
// Delete the child node
|
||||
$book->removeChild($chapter);
|
||||
|
||||
// paste the namespace URI back into the parent node
|
||||
$book->namespaceURI = $nsuri;
|
||||
?>]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="notes">
|
||||
&reftitle.notes;
|
||||
<note>
|
||||
<para>
|
||||
After calling this method, the <literal>DOMNode::$namespaceURI</literal>
|
||||
property on the parent node will be reset to &null;. Above example shows
|
||||
how to work around it.
|
||||
</para>
|
||||
</note>
|
||||
</refsect1>
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
|
|
Loading…
Reference in a new issue