我尝试从json数组中提取数据但总是得到空字符串。 p>
我的XML: p>
<?xml version =“1.0”encoding =“UTF-8”?>
< ItemList>
< Entry Item =“test1”Object =“1tset”/>
< Entry Item =“test2”Object =“2tset”/>
< / ItemList>
code> pre>
我的XML转储: p>
array(1){[“Entry”] => array(2)
{[0] => array(1){[“@attributes”] => array(2){[“Item”] => string(5)“test1”[“Object”] => string(5)“1tset”}}
[1] => array(1){[“@attributes”] => array(2){[“Item”] => string(5)“test2”[“Object”] => string(5)“2tset”}}}}
code> pre>
我的php代码: p>
$ xmlString =“ my.xml“;
$ xmlObject = simplexml_load_file($ xmlString);
$ xmltovar = json_decode(json_encode($ xmlObject),true);
foreach($ xmltovar ['Entry'] as $ test) {
echo $ test ['Item']。“< br>”;
}
code> pre>
我需要获取所有“项目”或 ItemList->条目标签中的“对象”。 p>
div>