Skip to main content
deleted 153 characters in body
Source Link
Giacomo1968
  • 25.3k
  • 11
  • 78
  • 106

(Originally published by me at youkey.krasnoludken.pl on Thursday, August 20th, 2009 at 11:13 pm )

Idea about helper functions is from one of the comments for DOM on php.net and idea about using unset is from kavoir.com. For me this solution finally worked:

function Myunset($node) { unsetChildren($node); $parent = $node->parentNode; unset($node); } function unsetChildren($node) { while (isset($node->firstChild)) { unsetChildren($node->firstChild); unset($node->firstChild); } } 

using it: $xml is SimpleXmlElement

Myunset($xml->channel->item[$i]); 

The result is stored in $xml, so don’t worry about assigning it to any variable.

(Originally published by me at youkey.krasnoludken.pl on Thursday, August 20th, 2009 at 11:13 pm )

Idea about helper functions is from one of the comments for DOM on php.net and idea about using unset is from kavoir.com. For me this solution finally worked:

function Myunset($node) { unsetChildren($node); $parent = $node->parentNode; unset($node); } function unsetChildren($node) { while (isset($node->firstChild)) { unsetChildren($node->firstChild); unset($node->firstChild); } } 

using it: $xml is SimpleXmlElement

Myunset($xml->channel->item[$i]); 

The result is stored in $xml, so don’t worry about assigning it to any variable.

Idea about helper functions is from one of the comments for DOM on php.net and idea about using unset is from kavoir.com. For me this solution finally worked:

function Myunset($node) { unsetChildren($node); $parent = $node->parentNode; unset($node); } function unsetChildren($node) { while (isset($node->firstChild)) { unsetChildren($node->firstChild); unset($node->firstChild); } } 

using it: $xml is SimpleXmlElement

Myunset($xml->channel->item[$i]); 

The result is stored in $xml, so don’t worry about assigning it to any variable.

Source Link

(Originally published by me at youkey.krasnoludken.pl on Thursday, August 20th, 2009 at 11:13 pm )

Idea about helper functions is from one of the comments for DOM on php.net and idea about using unset is from kavoir.com. For me this solution finally worked:

function Myunset($node) { unsetChildren($node); $parent = $node->parentNode; unset($node); } function unsetChildren($node) { while (isset($node->firstChild)) { unsetChildren($node->firstChild); unset($node->firstChild); } } 

using it: $xml is SimpleXmlElement

Myunset($xml->channel->item[$i]); 

The result is stored in $xml, so don’t worry about assigning it to any variable.