I want to parse a xml document which is located on another domain. I want to do this with PHP. Is it possible?
I've already try simpleXML but it doesn't seems to work.
I want to parse a xml document which is located on another domain. I want to do this with PHP. Is it possible?
I've already try simpleXML but it doesn't seems to work.
WEll first of all: http://www.stevymahy.com/xml/test.xml has malformed XML. You will not be able to parse this document until its fixed.
<?xml version="1.0" encoding="utf-8"?>
<mahy>
<!-- Diaporama -->
<diaporama duree="4">
<photo fichier="/admin/uploads/stevy01_001.jpg"></photo>
<photo fichier="/admin/uploads/stevy05_001.jpg"></photo>
<photo fichier="/admin/uploads/stevy06_001.jpg"></photo>
<photo fichier="/admin/uploads/DSC_8133-Modifier.jpg"></photo>
<photo fichier="/admin/uploads/appuyevelo.jpg"></photo>
<photo fichier="/admin/uploads/atriumplus.jpg"></photo>
<photo fichier="/admin/uploads/balancoirine.jpg"></photo>
</diaporama>
<!-- Biographie -->
<bio textetaille="16" ><![CDATA[jhkjdhgkjdhgjksdghkjshgjkshdgjkhsdgjksdhgjksdhgkj]]></bio>
It just trails off... EDIT: I've posted the full XML. It doesn't trail off (anymore?). However the diaporama and bio elements must be contained in a common root node. so maybe wrap everything in <root>
http://www.php.net/manual/en/function.file-get-contents.php http://www.php.net/manual/en/simplexml.examples-basic.php
// Get the contents of the XML
$str_xml = file_get_contents('http://www.stevymahy.com/xml/test.xml');
// Parse the XML
$obj_xml = new SimpleXMLElement($str_xml);
// ...do something with the parsed XML object