所以,我正在尝试解析和 xml 并从中获取一些值:
$xml = simplexml_load_string(file_get_contents('http://www.bnr.ro/nbrfxrates.xml'));
$currency = [];
foreach($xml->Body->Cube->Rate as $rate)
{
$currency[] = [
"name" => $rate["currency"],
"value" => $rate,
"multiplier" => $rate["multiplier"]
];
}
return $currency;
我的 $rate 变量应该是 Rate 标签内的值(例如:1.0806),而不是它给我这个:
object(SimpleXMLElement)[110]
public '@attributes' =>
array (size=1)
'currency' => string 'AED' (length=3)