See previous two parts to get better understanding of how these tricks works. Example shown here refers to part two. (Sorry, length limitation)
3. Tricks
<?php
// The real profit is in combination of property and array accesses and unset($someNode->{0}) trick -
// it allows you to remove whatever node you want:
unset($rootNode->{'div'}[2]); // remove node with * mark (text*)
// Another trick is removing child node using child node object
$newChildNode = $rootNode->addChild('div','text**'); // Create
unset($newChildNode->{0}); // Remove, node removed from parent object too!
echo "--2--\n".$rootNode->asXML();
/*
<xml_root>complex node
<type_one>renewed node 1</type_one>
<type_two>node 3</type_two>
<type_one>node 2</type_one>
<div>text</div>
<div>text</div>
<div>text</div>
</xml_root>
*/
?>