If you ask in your question about removing all <child> elements until there is only one left, you can do that with a simple while-loop:
<?php
/**
 * skip 2 element in xml code with php
 *
 * @link https://stackoverflow.com/q/31879798/367456
 */
$string = <<<XML
<root>
 <child>child1</child>
 <child>child2</child>
 <child>child3</child>
</root>
XML;
$xml   = simplexml_load_string($string);
$child = $xml->child;
while ($child->count() > 1) {
    unset($child[0]);
}
$xml->asXML('php://output');
The output is (also: online-demo):
<?xml version="1.0"?>
<root>
 <child>child3</child>
</root>
if you're only concerned to get the last element, use an xpath query as it has been suggested in the other answer. Do not even consider to use the array mish-mash of json encode decode - will only break the data you need to retain in the end.