PHPackages                             clearstream/xml-to-array - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. clearstream/xml-to-array

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

clearstream/xml-to-array
========================

Incredibly simple XML to array PHP converter

0.4.0(2y ago)6737.9k↑333.3%GPL-3.0-onlyPHPPHP ^7.4|^8.0CI passing

Since Mar 10Pushed 1y ago3 watchersCompare

[ Source](https://github.com/clearstream/xml-to-array)[ Packagist](https://packagist.org/packages/clearstream/xml-to-array)[ Docs](https://github.com/clearstream/xml-to-array)[ RSS](/packages/clearstream-xml-to-array/feed)WikiDiscussions main Synced 3w ago

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

XML to array PHP converter
==========================

[](#xml-to-array-php-converter)

This package provides a very simple class to convert XML string to array.

**Why should I use this package?**

- because you don't like XML
- because other packages generate inconsistent array structure
- because you can't serialize SimpleXML objects (but can serialize arrays)
- because you just want to use arrays

Install
-------

[](#install)

You can install this package via composer.

```
composer require clearstream/xml-to-array
```

Usage
-----

[](#usage)

```
use Clearstream\XmlToArray\XmlToArray;

$xml =

XML;

$array = XmlToArray::convert($xml);
```

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

```
[
    'response' => [
        '@success' => 'true',
        '#text' => '',
        'users' => [
            [
                '#text' => '',
                'user' => [
                    [
                        '@id' => '1',
                        '@name' => 'Illia',
                        '#text' => '',
                    ],
                    [
                        '@id' => '2',
                        '@name' => 'Trevor',
                        '#text' => '',
                    ],
                ],
            ],
        ],
        'settings' => [
            [
                '#text' => '',
                'mode' => [
                    [
                        '@value' => 'light',
                        '#text' => '',
                    ],
                ],
                'color' => [
                    [
                        '@value' => 'purple',
                        '#text' => '',
                    ],
                ],
            ],
        ],
        'article' => [
            [
                '@id' => '1',
                '#text' => 'Hello World!',
            ],
        ],
        'empty' => [
            ['#text' => ''],
        ],
        'cdata' => [
            ['#text' => 'John Doe'],
        ],
    ],
]
```

If your input contains something that cannot be parsed a `\Clearstream\XmlToArray\XmlToArrayException` will be thrown.

Testing
-------

[](#testing)

```
vendor/bin/phpunit
```

License
-------

[](#license)

GNU GENERAL PUBLIC LICENSE. Please see [License File](LICENSE) for more information.

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 77.8% 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

Every ~319 days

Total

4

Last Release

973d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/70cdcfc0afc84c662690a2a72599f6df77e50d4896ea8232646eec36ef4bc06c?d=identicon)[clearstream](/maintainers/clearstream)

---

Top Contributors

[![hivokas](https://avatars.githubusercontent.com/u/22997803?v=4)](https://github.com/hivokas "hivokas (7 commits)")[![paulandroshchuk](https://avatars.githubusercontent.com/u/13240539?v=4)](https://github.com/paulandroshchuk "paulandroshchuk (1 commits)")[![trevorgehman](https://avatars.githubusercontent.com/u/3209864?v=4)](https://github.com/trevorgehman "trevorgehman (1 commits)")

---

Tags

xmlarrayconvert

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/clearstream-xml-to-array/health.svg)

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

###  Alternatives

[openlss/lib-array2xml

Array2XML conversion library credit to lalit.org

31053.4M49](/packages/openlss-lib-array2xml)[digitickets/lalit

GitHub copy of LaLit's XML2Array and Array2XML

721.6M7](/packages/digitickets-lalit)

PHPackages © 2026

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