PHP code example of krosscode / xml-to-object
1. Go to this page and download the library: Download krosscode/xml-to-object library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
krosscode / xml-to-object example snippets
// Using composer here, but you can also directly include XmlToObject.php
// First we need to get the contents of our XML file
$xmlContents = file_get_contents('path/to/xml/file.xml');
if (!$xmlContents) return false; // File couldn't be read
// Now we try to convert the XML to an object
$xmlObject = xmlToObject($xmlContents);
if (!$xmlObject) return false; // XML couldn't be converted to an object
print_r($xmlObject); // Success!