bupy7/xml-constructor

The XML of document structure constructor.

1.3.0 2018-11-21 19:54 UTC

README

Latest Stable Version Total Downloads Latest Unstable Version License Build Status Coverage Status

The XML of document structure constructor.

Install

Add the following to require section of your composer.json:

"bupy7/xml-constructor": "*"

Then do composer install.

Usage

$xml = new XmlConstructor();
$in = [
    [
        'tag' => 'root',
        'elements' => [
            [
                'tag' => 'tag1',
                'attributes' => [
                    'attr1' => 'val1',
                    'attr2' => 'val2',
                ],
            ],
            [
                'tag' => 'tag2',
                'content' => 'content2',
            ],
            [
                'tag' => 'tag3',
                'elements' => [
                    [
                        'tag' => 'tag4',
                        'content' => 'content4',
                    ],
                ],
            ],
        ],
    ],
];
echo $xml->fromArray($in)->toOutput();

if you send data to browser raw, use header for content type:

header('Content-Type: application/xml; charset=utf-8');

License

xml-constructor is released under the BSD 3-Clause License. See the bundled LICENSE.md for details.