I have the xml example:
<Listings>
<Listing>
<Title>Nome</Title>
<Details>
<Description>
dados
</Description>
</Details>
<Media>
<Item medium="image">
https://site.com.br/PM.jpeg
</Item>
<Item medium="image">
https://site.com.br/PM.jpeg
</Item>
<Item medium="image">
https://site.com.br/PM.jpeg
</Item>
</Media>
</Listing>
<Listing>
<Title>Nome</Title>
<Details>
<Description>
dados
</Description>
</Details>
<Media>
<Item medium="image">
https://site.com.br/PM.jpeg
</Item>
<Item medium="image">
https://site.com.br/PM.jpeg
</Item>
<Item medium="image">
https://site.com.br/PM.jpeg
</Item>
</Media>
</Listing>
</Listings>
I'm reading with the function simplexml_load_file
, reading the data occurs normally, my problem is like reading all the items inside the <Media>
I tried the following:
foreach($xml->Listings as $registro):
echo 'Título: ' . $registro->Listing->Title . '<br>';
foreach($registro->Listing->Media as $item):
echo 'Imagem: ' . $item->Item . '<br>';
endforeach;
endforeach;