我想从像这样的xml文件创建一个php数组
的test.xml
object(SimpleXMLElement)#3 (2) { ["uebertragung"]=> object(SimpleXMLElement)#5 (1) { ["@attributes"]=> array(9)
{ ["art"]=> string(7) "OFFLINE" ["umfang"]=> string(4) "TEIL"
["modus"]=> string(3) "NEW" ["version"]=> string(5) "1.2.7" ["sendersoftware"]=> string(7) "crm11" ["senderversion"]=> string(3) "1.1"
["techn_email"]=> string(18) "support@mail.com" ["timestamp"]=> string(19)
"2014-06-01T10:00:00" ["regi_id"]=> string(7) "ABCD143" } }
["anbieter"]=> object(SimpleXMLElement)#4 (3) { ["anbieternr"]=>
string(6) "144185" ["firma"]=> string(14) "redfirm"
["immobilie"]=> object(SimpleXMLElement)#6 (7) { ["objektkategorie"]=> object(SimpleXMLElement)#7 ...
mycode的:
$xml = simplexml_load_file("test.xml") or die("Error: Cannot read xml file");
var_dump($xml);
echo "show1: " .$xml->openimmo->uebertragung->{'art'} . "<br>";
echo "show2: " .$xml->openimmo->uebertragung['art'];
显示1 + 2显示什么,有人可以帮助我,我不理解数组结构?
答案 0 :(得分:0)
艺术是一种属性,所以你可以通过
获得它的价值$xml->openimmo->uebertragung->attributes()->art
更多信息 http://php.net/manual/en/simplexmlelement.attributes.php