PHP SimpleXML: Remove items with for
I just can remove an item from a simpleXML element with: unset($this->simpleXML->channel->item[0]); but I can't with the a for: $items = $this->simpleXML->xpath('/rss/channel/item'); for($i = count($items); $i > $itemsNumber; $i--) { unset($items[$i - 1]); } some items are removed from $items (Netbeans Debug can confirm that) but when I get the path again (/rss/channel/item) nothing was deleted. What's wrong? Xavier Barbosa SimpleXML does not handle node deletion, you need to use DOMNode for this. Happily, when you import your nodes into DOMNode, the instances point to the same tree. So, you