I try to extract data from an json array but always i got empty string.
My XML:
<?xml version="1.0" encoding="UTF-8"?>
<ItemList>
<Entry Item = "test1" Object = "1tset" />
<Entry Item = "test2" Object = "2tset" />
</ItemList>
My Dump from XML:
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" } } } }
My php code:
$xmlString = "my.xml";
$xmlObject = simplexml_load_file($xmlString);
$xmltovar = json_decode(json_encode($xmlObject), true);
foreach($xmltovar['Entry'] as $test) {
echo $test['Item']."<br>";
}
I need to get all "Item"or "Object" from ItemList->Entry Tag.