To get to print out only the film need to navigate to the correct point:
$xml->CINEMAS->CINEMA->FILMES->FILME
For example:
<?php
$url = 'http://www.multicinecinemas.com.br/webservice/'
$url .= '?chave=c99e34ed77750774417e5a9d2a2f5135&tipo=cinema';
$xml = simplexml_load_file($url);
foreach($xml->CINEMAS->CINEMA->FILMES->FILME as $filme)
{
echo $filme->CODIGO;
echo ' ';
echo $filme->NOME;
echo ' ';
echo $filme->HORARIO;
echo ' ';
echo "<br>";
}
To repeat the same process for several files use a function as is:
function toPrint(array $array = array())
{
foreach($array as $items)
{
foreach($items->CINEMAS->CINEMA->FILMES->FILME as $filme)
{
echo $filme->CODIGO;
echo ' ';
echo $filme->NOME;
echo ' ';
echo $filme->HORARIO;
echo ' ';
echo "<br>";
}
}
}
$url = 'http://www.multicinecinemas.com.br/webservice/'
$url .= '?chave=c99e34ed77750774417e5a9d2a2f5135&tipo=cinema';
$xml = simplexml_load_file($url);
toPrint(array($xml1, $xml2));
The form q vc is iterating the xml that is wrong. Note that in the structure of the file vc does not start with film, it starts with cinemas > cinema > movies
– gmsantos
How do I make it work? I don’t know about these "sub-levels"
– haRdy