simplexml_load_stringの使い方 2

<h3>xml</h3>
<?php

$axmlData = array();
$axmlData&#91;0&#93; = array 
		(
			"name"=> "楽天日本株4.3倍ブル",
			"rate" => "123.54",
			"asset" => "27625"
		);
$axmlData[1] = array
		(
			"name" => "小型株ファンド",
			"rate" => "107.11",
			"asset" => "24381"
		);
$sStringXML = '<?xml version="1.0" encoding="UTF-8"?>'."\n";
echo $axmlData[0][rate];
$sStringXML .= "<list>"."\n";
foreach($axmlData as $value){
	$sStringXML .= "<item>";
	$sStringXML.= "<return>".$value['rate']."</return>";
	$sStringXML .= "<toshin>".$value['name']."</toshin>";

	$sStringXML .= "<shisan>".$value['asset']."</shisan>";
	$sStringXML .= "</item>"."\n";
}
$sStringXML .= "</list>"."\n";
echo '[PHP ruler="true" toolbar="true"]'.htmlentities($sStringXML, ENT_QUOTES, 'UTF-8').'<\/pre>';
echo "<br>";
$xml = simplexml_load_string($sStringXML);

foreach($xml->item as $value){
	$name = $value->toshin;
	$return = $value->return;
	$asset = $value->shisan;

	echo 'name:'.$name.'<br/>';
	echo 'return:'.$return.'<br/>';
	echo 'asset:'.$asset.'<br>';
}
?>

name:楽天日本株4.3倍ブル
return:123.54
asset:27625
name:小型株ファンド
return:107.11
asset:24381

つまり、下記のxml:return, toshin, shisanを切り取ってくれるということですね。

<?xml version="1.0" encoding="UTF-8"?> <list> <item><return>123.54</return><toshin>楽天日本株4.3倍ブル</toshin><shisan>27625</shisan></item> <item><return>107.11</return><toshin>小型株ファンド</toshin><shisan>24381</shisan></item> </list>