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

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

alextartan/xml2array
====================

Lightweight xml&lt;-&gt;array conversion.

2.0.2(5y ago)643.5k↓12.9%[6 PRs](https://github.com/alextartan/xml2array/pulls)1Apache-2.0PHPPHP &gt;=7.4

Since Aug 29Pushed 3y ago1 watchersCompare

[ Source](https://github.com/alextartan/xml2array)[ Packagist](https://packagist.org/packages/alextartan/xml2array)[ Docs](https://github.com/alextartan/xml2array)[ RSS](/packages/alextartan-xml2array/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (8)Dependencies (7)Versions (23)Used By (1)

#### Array &lt;-&gt; XML conversion package

[](#array---xml-conversion-package)

Lightweight XML parser

Current build status
====================

[](#current-build-status)

[![Build Status](https://camo.githubusercontent.com/1cadfc44fd059721559b72c2d77c9378bc71e1860ae679dd757060923e4d62d5/68747470733a2f2f7472617669732d63692e6f72672f616c657874617274616e2f786d6c3261727261792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/alextartan/xml2array)[![codecov](https://camo.githubusercontent.com/5ef6aef7a976d914b3e6ff33ec4b58a811898dee01a8c9ae5f8eb9435a00e895/68747470733a2f2f636f6465636f762e696f2f67682f616c657874617274616e2f786d6c3261727261792f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/alextartan/xml2array)[![Infection MSI](https://camo.githubusercontent.com/b41516bf9d5e375d7c27e7db3da4c3b987a693784f226647a09bb18f54cf7b93/68747470733a2f2f62616467652e737472796b65722d6d757461746f722e696f2f6769746875622e636f6d2f616c657874617274616e2f786d6c3261727261792f6d6173746572)](https://stryker-mutator.github.io)[![Dependabot Status](https://camo.githubusercontent.com/6f84f0ac5969e7e6535a9129a9c687a36c49f846610ada4885214ed43fb8a5a1/68747470733a2f2f6170692e646570656e6461626f742e636f6d2f6261646765732f7374617475733f686f73743d676974687562267265706f3d616c657874617274616e2f786d6c326172726179)](https://dependabot.com)[![Downloads](https://camo.githubusercontent.com/dc3fc9b2672eaed3d2c0a4dfc42354ae822fa72dc5057386f1e79af316f1b9ac/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f64796e616d69632f6a736f6e2e7376673f75726c3d68747470733a2f2f7265706f2e7061636b61676973742e6f72672f7061636b616765732f616c657874617274616e2f786d6c3261727261792e6a736f6e266c6162656c3d446f776e6c6f6164732671756572793d242e7061636b6167652e646f776e6c6f6164732e746f74616c26636f6c6f72423d6f72616e6765)](https://packagist.org/packages/alextartan/xml2array)

Install
=======

[](#install)

The easiest way is to use `composer`:

```
composer require alextartan/xml2array

```

Notes:

Latest release requires `PHP` &gt;= 7.2 and the `dom` extension (`ext-dom`)

For `PHP` &lt;= 7.2, use version `1.0.2`

Usage
=====

[](#usage)

###### ArrayToXml

[](#arraytoxml)

Convert an XML (either DOMDocument or string) to an array

```
// default value:
$config =  [
    'version'             => '1.0',
    'encoding'            => 'UTF-8',
    'attributesKey'       => '@attributes',
    'cdataKey'            => '@cdata',
    'valueKey'            => '@value',
    'useNamespaces'       => false,
    'forceOneElementArray => false,
];

$xtoa  = new XmlToArray($config);
$array = $xtoa->buildArrayFromString($xmlString);
$array = $xtoa->buildArrayFromDomDocument($xmlDom);

```

###### XmlToArray

[](#xmltoarray)

Convert an array to a DOMDocument

```
// default value:
$config =  [
    'version'       => '1.0',
    'encoding'      => 'UTF-8',
    'attributesKey' => '@attributes',
    'cdataKey'      => '@cdata',
    'valueKey'      => '@value',
    'formatOutput'  => false,
];

$atox = new ArrayToXml($config);
$xml  = $atox->buildXml($array);

```

Issues and pull requests.
=========================

[](#issues-and-pull-requests)

Any issues found should be reported in this repository issue tracker, issues will be fixed when possible. Pull requests will be accepted, but please adhere to the PSR2 coding standard. All builds must pass in order to merge the PR.

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 68.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

Every ~53 days

Recently: every ~101 days

Total

16

Last Release

2062d ago

Major Versions

0.5.0 → 1.0.12018-09-28

1.3.1 → 2.0.02020-01-20

PHP version history (4 changes)0.0.1PHP &gt;=5.3.2

0.1.0PHP &gt;=7.0

1.1.0PHP &gt;=7.2

2.0.0PHP &gt;=7.4

### Community

Maintainers

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

---

Top Contributors

[![alextartan](https://avatars.githubusercontent.com/u/1787996?v=4)](https://github.com/alextartan "alextartan (81 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (28 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (6 commits)")[![atirtan](https://avatars.githubusercontent.com/u/74187125?v=4)](https://github.com/atirtan "atirtan (3 commits)")

---

Tags

arrayphp7xmlxmlarrayconversion

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k13.2M174](/packages/cuyz-valinor)[openlss/lib-array2xml

Array2XML conversion library credit to lalit.org

31053.8M53](/packages/openlss-lib-array2xml)[digitickets/lalit

GitHub copy of LaLit's XML2Array and Array2XML

721.7M7](/packages/digitickets-lalit)[hiraku/xml_builder

Simple DSL for building XML

141.6k1](/packages/hiraku-xml-builder)

PHPackages © 2026

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