PHP code example of sallyx / nette-xml-adapter

1. Go to this page and download the library: Download sallyx/nette-xml-adapter 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/ */

    

sallyx / nette-xml-adapter example snippets


[key1 => 'value1', key2=>'value2']

[0=>'value1',1=>'value2]

["trimmed string", " string with spaces  ","1", 2, TRUE, NULL]

["1", "2", "3"]


use Sallyx\Nette\DI\Config\Adapters\XmlAdapter;

$adapter = new XmlAdapter;
$file = 'vendor/sallyx/nette-xml-adapter/tests/Adapters/files/xmlAdapter.xml';
$config = $adapter->load($file);
print_r($config);


use Nette\DI\Config\Adapters\NeonAdapter;
use Sallyx\Nette\DI\Config\Adapters\XmlAdapter;

$na = new NeonAdapter;
$xa = new XmlAdapter;
$config = $na->load('config.neon');
$xmlConfig = $xa->dump($config);
// pretty output
$domxml = new DOMDocument('1.0');
$domxml->preserveWhiteSpace = false;
$domxml->formatOutput = true;
$domxml->loadXML($xmlConfig);
echo $domxml->saveXML();