PHPackages                             multidimensional/dom-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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. multidimensional/dom-array

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

multidimensional/dom-array
==========================

Create a DOMDocument from an Array.

1.0.1(7y ago)2339MITPHPPHP &gt;=5.5

Since Feb 20Pushed 7y ago1 watchersCompare

[ Source](https://github.com/multidimension-al/dom-array)[ Packagist](https://packagist.org/packages/multidimensional/dom-array)[ RSS](/packages/multidimensional-dom-array/feed)WikiDiscussions master Synced 2d ago

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

Array to DOMDocument Converter
==============================

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

[![Build Status](https://camo.githubusercontent.com/2dd928c3c84c0075a1ea98cbc73959992d343a0c00d2a3220b1134b17211709c/68747470733a2f2f7472617669732d63692e6f72672f6d756c746964696d656e73696f6e2d616c2f646f6d2d61727261792e737667)](https://travis-ci.org/multidimension-al/dom-array)[![Latest Stable Version](https://camo.githubusercontent.com/8e11ad54a8a5c01a36f9e1f0ee799105c8fa614bac537f72b18caac33447ea4c/68747470733a2f2f706f7365722e707567782e6f72672f6d756c746964696d656e73696f6e616c2f646f6d2d61727261792f762f737461626c652e737667)](https://packagist.org/packages/multidimensional/dom-array)[![Code Coverage](https://camo.githubusercontent.com/1294bb07ffdfa354fce1b18acaa7ed6299414f4144aba9f9e89f38968568ee15/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d756c746964696d656e73696f6e2d616c2f646f6d2d61727261792f6261646765732f636f7665726167652e706e67)](https://scrutinizer-ci.com/g/multidimension-al/dom-array/)[![Minimum PHP Version](https://camo.githubusercontent.com/dd6bad85ee03cf570f4cf82ab69a80396fdbf48050af932f8f23aa551b0d1e5a/687474703a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230352e352d3838393242462e737667)](https://php.net/)[![License](https://camo.githubusercontent.com/0521ff7a23b106602d5fe0bc435abbfd0bd56ffa1fcaf70f21747fc994df71af/68747470733a2f2f706f7365722e707567782e6f72672f6d756c746964696d656e73696f6e616c2f646f6d2d61727261792f6c6963656e73652e737667)](https://packagist.org/packages/multidimensional/dom-array)[![Total Downloads](https://camo.githubusercontent.com/207afd7543b7e80369592fe71f6224505ab3ffcb48291252cd35357f2e714386/68747470733a2f2f706f7365722e707567782e6f72672f6d756c746964696d656e73696f6e616c2f646f6d2d61727261792f642f746f74616c2e737667)](https://packagist.org/packages/multidimensional/dom-array)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/5c4013a24eb3d95bcc23993c3671c9509c489213d893a5acfa5d044e3e5a2272/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d756c746964696d656e73696f6e2d616c2f646f6d2d61727261792f6261646765732f7175616c6974792d73636f72652e706e67)](https://scrutinizer-ci.com/g/multidimension-al/dom-array/)

This library extends the DOMDocument function by adding a `loadArray` function that converts PHP arrays to DOMDocument classes that can be used to generate XML, HTML and other types of code. This library does the opposite of our [XML-Array](https://github.com/multidimension-al/xml-array) library which converts XML to a PHP array.

Requirements
------------

[](#requirements)

- PHP 5.5+

Installation
============

[](#installation)

The easiest way to install this library is to use composer. To install, simply include the following in your `composer.json` file:

```
"require": {
    "multidimensional/dom-array": "*"
}

```

Or run the following command from a terminal or shell:

```
composer require --prefer-dist multidimensional/dom-array

```

You can also specify version constraints, with more information available [here](https://getcomposer.org/doc/articles/versions.md).

Usage
=====

[](#usage)

This library utilizes PSR-4 autoloading, so make sure you include the library near the top of your class file:

```
use Multidimensional\DomArray\DOMArray;
```

How to use in your code:

```
$dom = new DOMArray('1.0', 'utf-8');
$array = ['item' => ['subitem' => 'true', '@id' => '123']];
$dom->loadArray($array);
$xml = $dom->saveXML();

echo $xml;

/*
 *
 *    true
 *
 */
```

As shown in the example, attributes can be assigned by adding an `@` symbol before the attribute name.

*Null* and *Empty* arrays will generate a DOMDocument with no elements.

Contributing
============

[](#contributing)

We appreciate all help in improving this library by either adding functions or improving existing functionality. If you do want to add to our library, please ensure you use PSR-2 formatting and add unit testing for all added functions.

Feel free to fork and submit a pull request!

License
=======

[](#license)

```
MIT License

Copyright (c) 2017 - 2019 multidimension.al

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

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

Total

2

Last Release

2640d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6588235?v=4)[AJ Quick](/maintainers/ajquick)[@ajquick](https://github.com/ajquick)

---

Top Contributors

[![ajquick](https://avatars.githubusercontent.com/u/6588235?v=4)](https://github.com/ajquick "ajquick (27 commits)")

---

Tags

arraydomdocumentphpxml

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/multidimensional-dom-array/health.svg)

```
[![Health](https://phpackages.com/badges/multidimensional-dom-array/health.svg)](https://phpackages.com/packages/multidimensional-dom-array)
```

###  Alternatives

[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k472.8M135](/packages/mtdowling-jmespathphp)[opis/closure

A library that can be used to serialize closures (anonymous functions) and arbitrary data.

2.6k230.0M284](/packages/opis-closure)[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)[michelf/php-markdown

PHP Markdown

3.5k52.4M345](/packages/michelf-php-markdown)[jms/metadata

Class/method/property metadata management in PHP

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

PHPackages © 2026

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