/* Decoded by unphp.net */ --TEST-- SimpleXML: Adding an elements --EXTENSIONS-- simplexml --FILE-- EOF; function traverse_xml($xml, $pad = '') { $name = $xml->getName(); echo "$pad<$name"; foreach($xml->attributes() as $attr => $value) { echo " $attr=\"$value\""; } echo ">" . trim($xml) . " "; foreach($xml->children() as $node) { traverse_xml($node, $pad.' '); } echo $pad." "; } $people = simplexml_load_string($xml); traverse_xml($people); $people->person = 'Joe'; $people->person['gender'] = 'male'; traverse_xml($people); $people->person = 'Jane'; traverse_xml($people); $people->person['gender'] = 'female'; $people->person[1] = 'Joe'; $people->person[1]['gender'] = 'male'; traverse_xml($people); $people->person[3] = 'Minni-me'; $people->person[2]['gender'] = 'male'; traverse_xml($people); $people->person[3]['gender'] = 'error'; traverse_xml($people); ?> --EXPECTF-- Joe Jane Jane Joe Warning: main(): Cannot add element person number 3 when only 2 such elements exist in %s027.php on line %d Jane Joe Minni-me Jane Joe Minni-me