PHPackages                             midnite81/xml2array - 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. midnite81/xml2array

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

midnite81/xml2array
===================

A package to convert XML to an Array with the inbuilt ability to convert to Json, Laravel Collection and Serialize

v2.0.0(3y ago)338.8k↓41.9%12MITPHPPHP ^8.1

Since Jul 9Pushed 3y ago1 watchersCompare

[ Source](https://github.com/midnite81/xml2array)[ Packagist](https://packagist.org/packages/midnite81/xml2array)[ RSS](/packages/midnite81-xml2array/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (5)Used By (2)

Xml2Array
=========

[](#xml2array)

[![Latest Stable Version](https://camo.githubusercontent.com/8c6f9b01795f691ec7b3b342084fc0619341fb5c22919921d46bc3c486246ff4/68747470733a2f2f706f7365722e707567782e6f72672f6d69646e69746538312f786d6c3261727261792f76657273696f6e)](https://packagist.org/packages/midnite81/xml2array) [![Total Downloads](https://camo.githubusercontent.com/8ac53ee4b0f73795863b69f75b3ab26276382e63e6e1fff01fecd4877c27148d/68747470733a2f2f706f7365722e707567782e6f72672f6d69646e69746538312f786d6c3261727261792f646f776e6c6f616473)](https://packagist.org/packages/midnite81/xml2array) [![Latest Unstable Version](https://camo.githubusercontent.com/5d253648c34c91a1e0c7968f098544e12efc83fd6104d17f8eb016f3d0a3a4f8/68747470733a2f2f706f7365722e707567782e6f72672f6d69646e69746538312f786d6c3261727261792f762f756e737461626c65)](https://packagist.org/packages/midnite81/xml2array) [![License](https://camo.githubusercontent.com/cd30458ccca333d9846efaef2c1e81a8442124e1bfaeb57ca5aba6c62c51ce21/68747470733a2f2f706f7365722e707567782e6f72672f6d69646e69746538312f786d6c3261727261792f6c6963656e73652e737667)](https://packagist.org/packages/midnite81/xml2array) [![Build](https://camo.githubusercontent.com/22ddacaf3c76a9e59868398b8cec3259a78904ff8823ddfc34dbb300eba53679/68747470733a2f2f7472617669732d63692e6f72672f6d69646e69746538312f786d6c3261727261792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/midnite81/xml2array) [![Coverage Status](https://camo.githubusercontent.com/699484153bd0efea170ceba30b0a1e51038be2b643b8ebb207f83ea0f12103cd/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6d69646e69746538312f786d6c3261727261792f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/midnite81/xml2array?branch=master)
*Package based on [gaarf/XML-string-to-PHP-array](https://github.com/gaarf/XML-string-to-PHP-array)*

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

[](#installation)

To install through composer include the package in your `composer.json`.

*If you are using php 8.1+ use "^2.0.0" for php7 use "^1.0.0".*

```
"midnite81/xml2array": "^2.0.0"

```

Run `composer install` or `composer update` to download the dependencies, or you can run `composer require midnite81/xml2array`.

Example usage:
--------------

[](#example-usage)

```
use Midnite81\Xml2Array\Xml2Array;

$xml = Xml2Array::create($someXmlString);
// or $xml = (new Xml2Array())->convert($someXmlString);

```

If the string is invalid then an `IncorrectFormatException` will be thrown, otherwise an `XmlResponse` class will be returned.

You can access the `XmlResponse` class like an array, as such:

`echo $xml['result'];`

Other methods include:

MethodDescription`$xml->toArray();`Returns the array`$xml->toJson();`Returns as JSON`$xml->toCollection()`Returns as Laravel Collection\*`$xml->serialize()`Returns the array serialized`$xml->serialise()`Alias of above- It will throw an exception if you try to run `$xml->toCollection()` but you do not have the `collect` helper available.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~1470 days

Total

2

Last Release

1400d ago

Major Versions

v1.0.0 → v2.0.02022-07-19

### Community

Maintainers

![](https://www.gravatar.com/avatar/edf6a9952472e4cdd5a0e12ad3b9bd15b801c08a5cd56f33f6c8495aef4968ed?d=identicon)[midnite81](/maintainers/midnite81)

---

Top Contributors

[![midnite81](https://avatars.githubusercontent.com/u/254850?v=4)](https://github.com/midnite81 "midnite81 (18 commits)")

---

Tags

arrayphpxmlxml-parser

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/midnite81-xml2array/health.svg)

```
[![Health](https://phpackages.com/badges/midnite81-xml2array/health.svg)](https://phpackages.com/packages/midnite81-xml2array)
```

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k89.3M627](/packages/jms-serializer-bundle)[hassankhan/config

Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files

97513.5M170](/packages/hassankhan-config)[meyfa/php-svg

Read, edit, write, and render SVG files with PHP

54613.9M42](/packages/meyfa-php-svg)

PHPackages © 2026

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