Re: remove SimpleXML nodes

From: Date: Thu, 31 Aug 2006 16:31:15 +0000
Subject: Re: remove SimpleXML nodes
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-241290@lists.php.net to get a copy of this message
Yes, I agree. SimpleXML is limited. Do not expect to find advanced features in SimpleXML. Regards. On 8/31/06, Jay Paulson <Jay.Paulson@wholefoods.com> wrote:
So I want to do... $xmlDatabase = new SimpleXMLElement($myXML); foreach ($xmlDatabase as $oneTable) { if ($oneTable['name'] == 'two') {
      ///  ---- HERE I WANT TO DELETE THE $oneTable NODE
      unset($oneTable);   // <-- and this doesn't work...
} }
I tried to do the same a while back and could not figure it out. I think that SimpleXML is just that - simple. You should rather try using DOMXML functions, or as I did, roll an XML parser and do it like that. Why can't you just recreate the XML and skip the node you don't want to include? So something like below: foreach ($xmlDatabase as $oneTable) {
    // skip node you don't want in your final xml output
    if ($oneTable['name'] != 'two')
    {
        ....
    }
} -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
-- Anas Mughal

« previous php.general (#241290) next »