2017 © Pedro PelĂĄez
 

library php-to-xml

Convert php structure to xml file

image

bulton-fr/php-to-xml

Convert php structure to xml file

  • Sunday, October 23, 2016
  • by bulton-fr
  • Repository
  • 1 Watchers
  • 0 Stars
  • 182 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 21 % Grown

The README.md

php-to-xml

Convert php basic structure to xml document, (*1)

Build Status Coverage Status Scrutinizer Code Quality, (*2)

This library is to convert a basic php structure to xml document. Xml attributes is not implemented. The main goal is to convert a php structure to json or xml., (*3)

Install

With composer: curl -sS https://getcomposer.org/installer | php, (*4)

Add in your composer.json, (*5)

{
    "require": {
        "bulton-fr/php-to-xml": "@stable"
    }
}

 Example

PHP:, (*6)

$phpStructure = (object) [
    'elements' => (object) [
        'elemA' => [
            0 => (object) [
                'elemB' => 'Toto',
                'elemC' => 'Foo',
                'elemD' => (object) [
                    'elemE' => [
                        'Foo',
                        'Bar'
                    ]
                ]
            ],
            1 => (object) [
                'elemB' => 'Titi',
                'elemC' => 'Fii',
                'elemD' => (object) [
                    'elemE' => [
                        'Fii',
                        'Ber'
                    ]
                ]
            ]
        ]
    ]
];

echo json_encode($phpStructure);

$phpToXml = new \bultonFr\PhpToXml\PhpToXml;
echo $phpToXml->convert($phpStructure);

JSON:, (*7)

{
    "elements":{
        "elemA":[
            {
                "elemB":"Toto",
                "elemC":"Foo",
                "elemD":{
                    "elemE":[
                        "Foo",
                        "Bar"
                    ]
                }
            },
            {
                "elemB":"Titi",
                "elemC":"Fii",
                "elemD":{
                    "elemE":[
                        "Fii",
                        "Ber"
                    ]
                }
            }
        ]
    }
}

XML:, (*8)

<?xml version="1.0" encoding="UTF-8"?>
<elements>
    <elemA>
        <elemB>Toto</elemB>
        <elemC>Foo</elemC>
        <elemD>
            <elemE>Foo</elemE>
            <elemE>Bar</elemE>
        </elemD>
    </elemA>
    <elemA>
        <elemB>Titi</elemB>
        <elemC>Fii</elemC>
        <elemD>
            <elemE>Fii</elemE>
            <elemE>Ber</elemE>
        </elemD>
    </elemA>
</elements>

The Versions

23/10 2016

1.0.x-dev

1.0.9999999.9999999-dev https://github.com/bulton-fr/php-to-xml

Convert php structure to xml file

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.4.0

 

The Development Requires

xml

23/10 2016

dev-master

9999999-dev https://github.com/bulton-fr/php-to-xml

Convert php structure to xml file

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.4.0

 

The Development Requires

xml

23/10 2016

1.0.0

1.0.0.0 https://github.com/bulton-fr/php-to-xml

Convert php structure to xml file

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.4.0

 

The Development Requires

xml