On Mon, Feb 05, 2001 at 02:06:13PM +0100, Thomas Brusa wrote:
> hello
> I'm trying to parse and change a loaded xml-file using the DOM module.
> I need to remove certain nodes and append new ones.
> Is it really true that you can't remove a childnode 
> while working with dom. 
> in perl this would look somehow like this:
> 
>       $doc1->removeChild($tmpele);
>       $tmpele->setOwnerDocument($doc2);
>       $somedoc2node->appendChild($tmpele);
> 
> thanx
> tom

seems to be. i asked the same question some days ago and have no
direct solution so far. 

what i did to circumvent this is doing a xml->xml transformation (with
sablotron), copying everything but the node i want to delete.

the xsl looks like:

 -- snip --
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 

<xsl:template match="@*|*">
<xsl:copy>

<xsl:apply-templates select='@*|node()[not(@id="%deleteme%")]'/>

</xsl:copy>
</xsl:template>
</xsl:stylesheet>

 -- /snip --

everything but nodes with id of %deleteme% gets copied. this of course
ain't very pretty but works...

ru,
peter.
-- 
Peter Sabaini [EMAIL PROTECTED]
NETCONOMY Onlineberatungs- und -management Gmbh & Co KG
www.netconomy.net - Schoenaugasse 64, 8010 Graz
Tel. +43-(0)316 875-3081.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to