1. Go to this page and download the library: Download jackiedo/xml-array 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/ */
use Jackiedo\XmlArray\Array2Xml;
...
// We will use array from the result of first example as input for this example
$xmlString = Array2Xml::convert($array)->toXml(true);
$converter = new Xml2Array($config);
$array = $converter->convertFrom($inputXml)->toArray();
$converter = new Xml2Array;
$array = $converter->setConfig($config)->convertFrom($inputXml)->toArray();
$config = $converter->getConfig();
$defaultConfig = [
'version' => '1.0', // Version of XML document
'encoding' => 'UTF-8', // Encoding of XML document
'standalone' => null, // Standalone directive for XML document
'attributesKey' => '@attributes', // The key name use for storing attributes of node
'cdataKey' => '@cdata', // The key name use for storing value of Cdata Section in node
'valueKey' => '@value', // The key name use for storing text content of node
'namespacesOnRoot' => true // Collapse all the namespaces at the root node, otherwise it will put in the nodes for which the namespace first appeared.
];
$defaultConfig = [
'version' => '1.0', // Version of XML document
'encoding' => 'UTF-8', // Encoding of XML document
'standalone' => null, // Standalone directive for XML document
'attributesKey' => '@attributes', // The key name use for storing attributes of node
'cdataKey' => '@cdata', // The key name use for storing value of Cdata Section in node
'valueKey' => '@value', // The key name use for storing text content of node
'rootElement' => null, // The name of root node will be create automatically in process of conversion
'keyFixer' => true, // The automatically key normalization will be used during conversion. It can be bool|string|numeric|callable
];