PHPackages                             rufov/converter-array-xml - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. rufov/converter-array-xml

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

rufov/converter-array-xml
=========================

The class is designed to convert an XML document into a PHP array and vice versa

1.0.0(3y ago)08[1 issues](https://github.com/RufovSA/php-converter-array-xml/issues)[5 PRs](https://github.com/RufovSA/php-converter-array-xml/pulls)BSD-3-ClausePHPPHP &gt;=8.1CI passing

Since Feb 27Pushed 2w ago1 watchersCompare

[ Source](https://github.com/RufovSA/php-converter-array-xml)[ Packagist](https://packagist.org/packages/rufov/converter-array-xml)[ Docs](https://github.com/rufovS)[ Fund](https://vk.com/rufow)[ GitHub Sponsors](https://github.com/rufovS)[ RSS](/packages/rufov-converter-array-xml/feed)WikiDiscussions main Synced yesterday

READMEChangelog (1)Dependencies (4)Versions (11)Used By (0)

ConverterArrayXML
=================

[](#converterarrayxml)

[![Software License](https://camo.githubusercontent.com/a7d953c880516e66cbc40f3833498c010255e60ca0142114a22829dc66fe28e4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4253445f335f436c617573652d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

The class is designed to convert an XML document into a PHP array and vice versa

Installation
------------

[](#installation)

The package could be installed with composer:

```
composer require rufov/converter-array-xml

```

Usage
-----

[](#usage)

```
use RufovS\ConverterArrayXML\ConverterArrayXML;

$xml =
        Lightsaber

        Sauron
        Evil Eye

_XML;

$result = ConverterArrayXML::xmlToArr($xml);
```

After running this piece of code `$result` will contain:

```
$result = [
    'root' => [
        '_attributes' => [
                'xmlns:xs=' => 'http://www.w3.org/2001/XMLSchema',
                'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance'
        ],
        'GoodGuy' => [
             '_attributes' => [
                'attr1' => 'value'
            ],
            'name' => [
                '_cdata' => 'Luke Skywalker'
            ],
            'weapon' => 'Lightsaber'
        ],
        'BadGuy' => [
            'name' => 'Sauron',
            'weapon' => 'Evil Eye'
        ]
    ]
];
```

You can also convert an array to xml. This is done as follows:

```
use RufovS\ConverterArrayXML\ConverterArrayXML;

$array = [
    'root' => [
        '_attributes' => [
                'xmlns:xs=' => 'http://www.w3.org/2001/XMLSchema',
                'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance'
        ],
        'GoodGuy' => [
             '_attributes' => [
                'attr1' => 'value'
            ],
            'name' => [
                '_cdata' => 'Luke Skywalker'
            ],
            'weapon' => 'Lightsaber'
        ],
        'BadGuy' => [
            'name' => 'Sauron',
            'weapon' => 'Evil Eye'
        ]
    ]
];

$result = ConverterArrayXML::arrayToXml($array);
```

At the end you will get the following xml document.

```

        Luke Skywalker]]>
        Lightsaber

        Sauron
        Evil Eye

```

Testing
-------

[](#testing)

```
vendor/bin/phpunit
```

Contributors
------------

[](#contributors)

Thanks to all the people who already contributed!

[ ![Contributors](https://camo.githubusercontent.com/ea7b9e7156017b185e55451bebfcca38cce096f0d1f186a1124c662d68edecce/68747470733a2f2f636f6e7472696275746f72732d696d672e7765622e6170702f696d6167653f7265706f3d7275666f76532f7068702d636f6e7665727465722d61727261792d786d6c)](https://github.com/rufovS/php-converter-array-xml/graphs/contributors)Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

License
-------

[](#license)

The BSD-3-Clause license. Please see [License File](LICENSE.md) for more information.

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance63

Regular maintenance activity

Popularity4

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 63.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1223d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/88198d1b31083878cd6056a2b8411436356b7bada47797a4a4e00829f7d6e222?d=identicon)[rufov](/maintainers/rufov)

---

Top Contributors

[![RufovSA](https://avatars.githubusercontent.com/u/78026078?v=4)](https://github.com/RufovSA "RufovSA (14 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (7 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

arrayphpphp-libraryxmlxml-parserphpcomponent

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/rufov-converter-array-xml/health.svg)

```
[![Health](https://phpackages.com/badges/rufov-converter-array-xml/health.svg)](https://phpackages.com/packages/rufov-converter-array-xml)
```

###  Alternatives

[nikic/phlexy

Lexing experiments in PHP

162599.0k14](/packages/nikic-phlexy)[corveda/php-sandbox

A PHP library that can be used to run PHP code in a sandboxed environment

23796.2k2](/packages/corveda-php-sandbox)[bupy7/xml-constructor

The array-like constructor of XML document structure.

1339.5k](/packages/bupy7-xml-constructor)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
