- simplexml_load_string: documentation ( source)
<?php
$xml = "<root>
<parent>
<child name='Child1' />
<child name='Child2' />
<subparent>
naiya
</subparent>
</parent>
<child name='Child4' />
</root>";
$xml = simplexml_load_string( $xml);
$node = $xml->xpath( '//child[@name="Child2"]/*');
foreach ($node->childresn as $item){
echo "Value: ".$item;
}