PHP code example of muhammetsafak / toxml

1. Go to this page and download the library: Download muhammetsafak/toxml 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/ */

    

muhammetsafak / toxml example snippets


array(
    'encode'            => 'UTF-8', // String
    'version'           => '1.0', // String ("1.0" or "1.1")
    'attributesKey'     => '@attibutes', // String
    'cdataKey'          => '@cdata', // String
    'valueKey'          => '@value', // String
    'useNamespaces'     => false, // Boolean
    'rootNodeName'      => 'root', // String
);



$data = array();

$xml = new \MuhammetSafak\ToXML\XML();

header('Content-Type: application/xml; charset=utf-8');
echo $xml->withArray($data)
        ->toXML();



$source = file_get_contents('example.xml');

$xml = new \MuhammetSafak\ToXML\XML();
$data = $xml->withXML($source)
            ->toArray();