Skip to content
The XML of document structure constructor.
Branch: master
Clone or download
Latest commit 2431d0a Apr 19, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src 1.3.0 Nov 21, 2018
tests
.gitignore fixed versions Sep 18, 2017
.travis.yml fixed travis Nov 21, 2018
CHANGELOG.md 1.3.1 Apr 19, 2019
Dockerfile
LICENSE.md v1.2.0 Dec 21, 2015
README.md added cdata option Apr 19, 2019
composer.json 1.3.1 Apr 19, 2019
docker-compose.yml added docker, fixed tests Sep 18, 2017
phpunit.xml.dist

README.md

xml-constructor

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',
                    ],
                ],
            ],
            [
                'tag' => 'tag4',
                'content' => '<b>content4</b>',
                'cdata' => true, // by default - false
            ],
        ],
    ],
];
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.

You can’t perform that action at this time.