2016年3月24日木曜日

@attributes phpの処理 amazon

SimpleXMLElement Object
02(
03    [Argument] => Array
04        (
05            [0] => SimpleXMLElement Object
06                (
07                    [@attributes] => Array
08                        (
09                            [Name] => Timestamp
10                            [Value] => 2010-01-02T13:34:57Z
11                        )
12                )
13 
14            [1] => SimpleXMLElement Object
15                (
16                    [@attributes] => Array
17                        (
18                            [Name] => Version
19                            [Value] => 2009-10-01
20                        )
21                )
1$name $xml->Argument[0]->attributes()->Name;
2$value $xml->Argument[0]->attributes()->Value;
ただし、$name も $value もオブジェクトなので、文字列として利用したい場合は、次のようにキャストしておくと良い。

1$name = (string) $xml->Argument[0]->attributes()->Name;
2$value = (string) $xml->Argument[0]->attributes()->Value;

0 件のコメント: