xpath returning references to the parent simplexml object can bite you performance wise when processing large trees.
this bit me big time so looking for a solution I came up with a simple way to speed up the code.
'dereferencing' will yield instant results, code will be lighting fast.
sacrifice is losing the reference to the parent object, for simple read-only operation this should be ok.
<?php
$data = 'data.xml';
$rs = simplexml_load_file($data);
foreach($rs->xpath('//row') as $rsrow){
// 'derefence' into a seperate xml tree for performance
$row = simplexml_load_string($rsrow->asXML());
$v = $row->xpath('//field[@name="id"]');
}
?>