I have several identical elements with different attributes that I\'m accessing with SimpleXML:
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.