PHPackages                             subjective-php/dom - 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. subjective-php/dom

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

subjective-php/dom
==================

Collection of utility classes to work with DOMDocument

v3.2.1(2y ago)219.2k↓50.8%3[1 issues](https://github.com/subjective-php/dom/issues)MITPHPPHP ^7.0 || ^8.0

Since Jan 21Pushed 2y agoCompare

[ Source](https://github.com/subjective-php/dom)[ Packagist](https://packagist.org/packages/subjective-php/dom)[ RSS](/packages/subjective-php-dom/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (2)Versions (16)Used By (0)

SubjectivePHP\\DOM
==================

[](#subjectivephpdom)

[![Latest Stable Version](https://camo.githubusercontent.com/19c3364ad5e8cd8fd0095b416a0b91df6af5f49734df6d43e47ae9630db165fd/68747470733a2f2f706f7365722e707567782e6f72672f7375626a6563746976652d7068702f646f6d2f762f737461626c65)](https://packagist.org/packages/subjective-php/dom)[![Latest Unstable Version](https://camo.githubusercontent.com/7c3fb8feb33c872eed98d5ce7ef5e3b79cd5c103b3f231f05bf0506707ea7afa/68747470733a2f2f706f7365722e707567782e6f72672f7375626a6563746976652d7068702f646f6d2f762f756e737461626c65)](https://packagist.org/packages/subjective-php/dom)[![License](https://camo.githubusercontent.com/057a00fda3d5719979f7210b410d5bd44a2d007d07f9c1e39e7dd06262068a4b/68747470733a2f2f706f7365722e707567782e6f72672f7375626a6563746976652d7068702f646f6d2f6c6963656e7365)](https://packagist.org/packages/subjective-php/dom)

[![Total Downloads](https://camo.githubusercontent.com/61c00c693e47c0a4dcfbc12c093b6720664979c6591f1e94a0845488d3aca3af/68747470733a2f2f706f7365722e707567782e6f72672f7375626a6563746976652d7068702f646f6d2f646f776e6c6f616473)](https://packagist.org/packages/subjective-php/dom)[![Monthly Downloads](https://camo.githubusercontent.com/e7d9887bb59db6745a0b129dbab46d6feb46bb1fe28d9865cb333d5153b2aa2e/68747470733a2f2f706f7365722e707567782e6f72672f7375626a6563746976652d7068702f646f6d2f642f6d6f6e74686c79)](https://packagist.org/packages/subjective-php/dom)[![Daily Downloads](https://camo.githubusercontent.com/a8c949f85fefcbd913762d75f17f0688d91e60378f29d0319da8e1848503d8aa/68747470733a2f2f706f7365722e707567782e6f72672f7375626a6563746976652d7068702f646f6d2f642f6461696c79)](https://packagist.org/packages/subjective-php/dom)

[![Documentation](https://camo.githubusercontent.com/a5445bbf0a3a04a2ec4db113f8a4ada4e12b57d9b2de32d936fa17800bc9ca6e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7265666572656e63652d706870646f632d626c75652e7376673f7374796c653d666c6174)](http://www.pholiophp.org/subjective-php/dom)

A collection of utility classes to work with PHP DOM Objects

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

[](#requirements)

subjective-php\\dom requires PHP 7.0 (or later).

\##Composer To add the library as a local, per-project dependency use [Composer](http://getcomposer.org)! Simply add a dependency on `subjective-php/dom` to your project's `composer.json` file such as:

```
composer require subjective-php/dom
```

\##Contact Developers may be contacted at:

- [Pull Requests](https://github.com/subjective-php/dom/pulls)
- [Issues](https://github.com/subjective-php/dom/issues)

\##Run Unit Tests With a checkout of the code get [Composer](http://getcomposer.org) in your PATH and run:

```
composer install
./vendor/bin/phpunit
```

Examples
========

[](#examples)

### Convert an xml document to an array

[](#convert-an-xml-document-to-an-array)

```

    Gambardella, Matthew
    XML Developer's Guide
    Computer
    44.95
    2000-10-01
    An in-depth look at creating applications with XML.

    Ralls, Kim
    Midnight Rain
    Fantasy
    5.95
    2000-12-16
    A former architect battles corporate zombies, an evil sorceress, and her own childhood to become queen of the world.

XML;

$document = new \DOMDocument();
$document->loadXml($xml);
$array = Util\DOMDocument::toArray($document);

var_export($array);
```

Output will be similar to:

```
array (
  'catalog' =>
  array (
    'book' =>
    array (
      0 =>
      array (
        '@id' => 'bk101',
        'author' => 'Gambardella, Matthew',
        'title' => 'XML Developer\'s Guide',
        'genre' => 'Computer',
        'price' => '44.95',
        'publish_date' => '2000-10-01',
        'description' => 'An in-depth look at creating applications with XML.',
      ),
      1 =>
      array (
        '@id' => 'bk102',
        'author' => 'Ralls, Kim',
        'title' => 'Midnight Rain',
        'genre' => 'Fantasy',
        'price' => '5.95',
        'publish_date' => '2000-12-16',
        'description' => 'A former architect battles corporate zombies, an evil sorceress, and her own childhood to become queen of the world.',
      ),
    ),
  ),
)

```

### Convert an array to XML

[](#convert-an-array-to-xml)

```

    Corets, Eva
    The Sundered Grail
    Fantasy
    5.95
    1000094400
    The two daughters of Maeve, half-sisters, battle one another for control of England. Sequel to Oberon's Legacy.

    Randall, Cynthia
    Lover Birds
    Romance
    4.95
    967867200
    When Carla meets Paul at an ornithology conference, tempers fly as feathers get ruffled.

```

### Construct XML document using xpaths

[](#construct-xml-document-using-xpaths)

```

    Lover Birds
    4.95

    The Sundered Grail
    Fantasy

```

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 98.1% 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 ~222 days

Recently: every ~489 days

Total

15

Last Release

1072d ago

Major Versions

v0.4.0 → v1.0.02015-09-20

v1.0.0 → v2.0.02016-08-09

v2.1.1 → v3.0.02018-03-15

PHP version history (5 changes)v0.1.1PHP ~5.4

v0.3.0PHP ~5.4 || ~7.0

v2.0.0PHP ~5.6 || ~7.0

v3.0.0PHP ^7.0

v3.2.0PHP ^7.0 || ^8.0

### Community

Maintainers

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

---

Top Contributors

[![chadicus](https://avatars.githubusercontent.com/u/1182337?v=4)](https://github.com/chadicus "chadicus (101 commits)")[![bartko-s](https://avatars.githubusercontent.com/u/675883?v=4)](https://github.com/bartko-s "bartko-s (1 commits)")[![hthiyaga](https://avatars.githubusercontent.com/u/35855544?v=4)](https://github.com/hthiyaga "hthiyaga (1 commits)")

---

Tags

xmldomdomdocument

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/subjective-php-dom/health.svg)

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

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k269.7M322](/packages/masterminds-html5)[sabre/xml

sabre/xml is an XML library that you may not hate.

55234.6M141](/packages/sabre-xml)[veewee/xml

XML without worries

1837.0M39](/packages/veewee-xml)[fluentdom/fluentdom

A fluent api for the php dom extension.

342312.4k17](/packages/fluentdom-fluentdom)[rct567/dom-query

DomQuery is a PHP library that allows easy 'jQuery like' DOM traversing and manipulation

136269.4k4](/packages/rct567-dom-query)[duncan3dc/domparser

Wrappers for the standard DOMDocument class to provide extra functionality for html/xml parsing

10406.3k3](/packages/duncan3dc-domparser)

PHPackages © 2026

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