Example of XML import using Lavarel

1

Does anyone have a clear example to import XML using Laravel Parser or SimpleXML ...? I have a scenario where I have to import an XML from an external system that contains various information generated in an XML ... I need to get this XML generated and display this data in the site ... Thanks! All help is welcome

    
asked by anonymous 10.02.2017 / 20:11

1 answer

0

To get xml through a URL:

//se o caminho esteja hospedado noutro servidor
$url = "https://www.........";

//caso o caminho esteja hospedado no próprio servidor
//coloque o ficheiro no caminho: 'public/assets/xml/file.xml'
$url = asset('assets/xml/file.xml');

$data = file_get_contents($url);
$xml = simplexml_load_string($data);

dd($xml);

To access a child:

if(isset($xml->child)) {
    dd($xml->child);
}
    
11.03.2017 / 16:28