Example of importing XML using Lavarel

Asked

Viewed 1,648 times

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 generated XML and display this data on the site ... Thank you! All help is welcome

  • You have the address, you have the layout of the information, you’ve done some programming?

  • I’m trying to get the exact XML, to show better what I want to do... thanks for replying @Laerte

1 answer

1


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);
}
  • Apologies for the delay in this reply. Thank you for answering. I have the url where the system hosts the files but do not know how to read them. I already have all the xml files generated by the system. See the url: http://dianopolis.megasofttransparencia.com.br/dianopolis-transparencia/transparencia/index.xhtml

  • What do you mean? Where is xml?

  • I have an XML file with information, wanted to read all this information...

  • I edited in order to answer that question.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.