Re: XML-DOM

From: Date: Mon, 05 Feb 2001 13:30:36 +0000
Subject: Re: XML-DOM
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-38228@lists.php.net to get a copy of this message
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 p.sabaini@netconomy.net NETCONOMY Onlineberatungs- und -management Gmbh & Co KG www.netconomy.net - Schoenaugasse 64, 8010 Graz Tel. +43-(0)316 875-3081.

« previous php.general (#38228) next »