PHPackages                             mtownsend/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. [API Development](/categories/api)
4. /
5. mtownsend/xml-to-array

ActiveLibrary[API Development](/categories/api)

mtownsend/xml-to-array
======================

Easily convert valid xml to a php array.

2.0.0(5y ago)1163.5M—2%14[3 issues](https://github.com/mtownsend5512/xml-to-array/issues)20MITPHPPHP ~7.0|~8.0CI failing

Since Oct 17Pushed 5y ago4 watchersCompare

[ Source](https://github.com/mtownsend5512/xml-to-array)[ Packagist](https://packagist.org/packages/mtownsend/xml-to-array)[ RSS](/packages/mtownsend-xml-to-array/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (20)

Easily convert valid xml to a php array.

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

[](#installation)

Install via composer:

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

```

Quick start
-----------

[](#quick-start)

### Using the class

[](#using-the-class)

```
use Mtownsend\XmlToArray\XmlToArray;

$xml =  'fedex',
	'id' => '123',
	'tracking_number' => '9205590164917312751089'
];
```

### Using the global helper

[](#using-the-global-helper)

```
$xml =  'fedex',
	'id' => '123',
	'tracking_number' => '9205590164917312751089'
];
```

Helpers, methods, and arguments
-------------------------------

[](#helpers-methods-and-arguments)

**Static method**

`XmlToArray::convert($xml, $outputRoot = false)`

The `$outputRoot` determines whether or not the php array will have a `@root` key. Default is `false`.

**Helper**

`xml_to_array($xml, $outputRoot = false)`

Arguments are identical to `XmlToArray::convert` method.

Purpose
-------

[](#purpose)

XML has always been a challenge to work with in PHP compared to other data formats, such as JSON. This package aims to make integrating with XML files or api requests significantly easier. With this package, you might actually like interfacing with XML in your application now.

Other packages you may be interested in
---------------------------------------

[](#other-packages-you-may-be-interested-in)

- [mtownsend/collection-xml](https://github.com/mtownsend5512/collection-xml)
- [mtownsend/request-xml](https://github.com/mtownsend5512/request-xml)
- [mtownsend/response-xml](https://github.com/mtownsend5512/response-xml)

Credits
-------

[](#credits)

- Mark Townsend
- Adrien aka Gaarf
- [All Contributors](../../contributors)

Testing
-------

[](#testing)

You can run the tests with:

```
./vendor/bin/phpunit
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity58

Moderate usage in the ecosystem

Community26

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 88.9% 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 ~864 days

Total

2

Last Release

1906d ago

Major Versions

1.0.0 → 2.0.02021-02-27

PHP version history (2 changes)1.0.0PHP ~7.0

2.0.0PHP ~7.0|~8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/812987?v=4)[mtownsend](/maintainers/mtownsend)[@mtownsend](https://github.com/mtownsend)

---

Top Contributors

[![mtownsend5512](https://avatars.githubusercontent.com/u/4945553?v=4)](https://github.com/mtownsend5512 "mtownsend5512 (8 commits)")[![arthurperton](https://avatars.githubusercontent.com/u/4067531?v=4)](https://github.com/arthurperton "arthurperton (1 commits)")

---

Tags

apiarrayconvertxmlxml-filesxml-parserxml-to-arraylaravelxmlarrayconvert

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[spatie/array-to-xml

Convert an array to xml

1.2k57.8M225](/packages/spatie-array-to-xml)[mtownsend/response-xml

The missing XML support for Laravel's Response class.

1041.2M3](/packages/mtownsend-response-xml)[mtownsend/request-xml

The missing XML support for Laravel's Request class.

43432.5k](/packages/mtownsend-request-xml)[mtownsend/collection-xml

The missing XML support for Laravel's Collection class.

4440.3k](/packages/mtownsend-collection-xml)

PHPackages © 2026

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