<?php
$str = <<<XML
<?xml version='1.0' encoding='UTF-8'?>
<note></note>
XML;
//$xml = simplexml_load_string($str);
$xml = simplexml_load_file('demo.xml');
foreach($xml->item as $v){
unset();
echo $v->id,' <br /> ';//aaa <br />
echo $v->name,' <br /> ';//aaa <br />
//$attributes = $v->name->attributes();
//var_dump($attributes);
echo $v->name->attributes().' <br /> ';//aaa <br />
echo $v->name->attributes().' <br /> ';//aaa <br />
echo $v->age,' <br /> ';//aaa <br />
}
die;
$item=$xml->addChild('item');
$item->addChild('id','3');
$item->addChild('name','ccc_new')->addAttribute("type", "small");
$item->addChild('age','40');
$xml->asXML('demo.xml');
?>