PHPackages                             timkippdev/array-to-xml-converter - 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. timkippdev/array-to-xml-converter

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

timkippdev/array-to-xml-converter
=================================

PHP library to convert an array of data to XML

1.0.1(6y ago)563112MITPHPPHP ^7.1.3

Since Jul 25Pushed 6y agoCompare

[ Source](https://github.com/timkippdev/php-array-to-xml-converter)[ Packagist](https://packagist.org/packages/timkippdev/array-to-xml-converter)[ RSS](/packages/timkippdev-array-to-xml-converter/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependencies (1)Versions (3)Used By (2)

Array To XML Converter
======================

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

This package converts an array of data to XML.

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

[](#installation)

Install this package using [Composer](https://getcomposer.org/)

```
composer require timkippdev/array-to-xml-converter
```

Usage
-----

[](#usage)

```
use TimKippDev\ArrayToXmlConverter\ArrayToXmlConverter;

...

$data = [
    'product-1' => [
        '_attributes' => [
            'key' => 'value'
        ],
        'title' => 'Product One',
        'price' => [
            '_attributes' => [
                'locale' => 'us'
            ],
            '_value' => '$9.99'
        ]
    ],
    'product-2' => [
        'title' => 'Product Two',
        'price' => '$12.99'
    ]
];

$xml = ArrayToXmlConverter::convert($data);
```

The above example will generate the following result stored in the `$xml` variable.

Notice that the `_attributes` property can be used to add property values to the current node. If you need to add `_attributes` for a node with a single value, like "price" in the "product-1" node, you need to use `_value` to specify the value of the node.

For adding properties to the root none, see below in "Conversion Options".

```

    Product One
    $9.99

    Product Two
    $12.99

```

### Conversion Options

[](#conversion-options)

There is an optional second parameter for the `convert` method that accepts an array of "options" to override.

```
use TimKippDev\ArrayToXmlConverter\ArrayToXmlConverter;

...

$data = [
    'foo' => 'bar'
];

$xml = ArrayToXmlConverter::convert($data, [
    'encoding' => 'ISO-8859-15', // default - "UTF-8"
    'formatOutput' => true, // default - true
    'rootName' => 'new-root', // default - "root"
    'rootAttributes' => [
        'key' => 'value'
    ], // default - no attributes (empty array)
    'version' => '2.0' // default - "1.0"
]);
```

The above example will generate the following result stored in the `$xml` variable.

```

  bar

```

Running Tests
-------------

[](#running-tests)

```
php vendor/bin/phpunit
```

License
-------

[](#license)

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

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 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 ~2 days

Total

2

Last Release

2484d ago

### Community

Maintainers

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

---

Top Contributors

[![timkippdev](https://avatars.githubusercontent.com/u/37030721?v=4)](https://github.com/timkippdev "timkippdev (3 commits)")

---

Tags

phpxmlarrayconverter

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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