PHP code example of graze / xml-utils

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

    

graze / xml-utils example snippets


$array = [
    'child1' => 111,
    'child2' => 222
];

$xmlElement = new SimpleXMLElement('<root/>');

$xmlConverter = new Graze\XmlUtils\XmlConverter();
$xmlConverter->addArrayAsChildren($array, $xmlElement);

echo $xmlElement->asXml();

$array = [
    'child1' => [
        '@attributes' => [
            'id' => 123
        ]
    ]
];

$array = [
    'child' => [
        'first',
        'second'
    ]
];