How to clone an entire XML node including childnodes?
| From: | Eric Wiener | Date: | Tue, 05 Jun 2007 18:45:57 +0000 |
| Subject: | How to clone an entire XML node including childnodes? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-256122@lists.php.net to get a copy of this message | ||
Basically I am trying to turn something like this:
<div>Hello <i>Joe</i>, nice to meet you</div>
into this:
<p>Hello <i>Joe</i>, nice to meet you</p>
by making a new node, inserting before the old node and then removing
the old node.
The problem is that I am populating the value of the new node with the
$oldNode->nodeValue property which apparently only includes text, not
child nodes, so I end up with:
<p>Hello Joe, nice to meet you</p>
How do you get the entire node value including any subnodes that may
appear within?
This is basically a variation on my previous post about how to
DomDocument->renameNode().