SimpleXML does not return data from file [closed]

1

I'm using

asked by anonymous 06.01.2017 / 19:41

1 answer

2

To get to print , just movie needs 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 like this:

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));
    
06.01.2017 / 19:57