PHPackages                             innmind/xml - 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. innmind/xml

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

innmind/xml
===========

Library to abstract xml manipulation

9.1.0(2mo ago)017.2k↓48.9%1[1 issues](https://github.com/Innmind/XML/issues)2MITPHPPHP ~8.4CI passing

Since Oct 30Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/Innmind/XML)[ Packagist](https://packagist.org/packages/innmind/xml)[ Docs](http://github.com/Innmind/XML)[ RSS](/packages/innmind-xml/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (27)Used By (2)

XML
===

[](#xml)

[![Build Status](https://github.com/innmind/xml/workflows/CI/badge.svg?branch=master)](https://github.com/innmind/xml/actions?query=workflow%3ACI)[![codecov](https://camo.githubusercontent.com/e89883d019bdab53e519ed2ec2bba52adbe15871a88636af0cc6d9f2dddc711c/68747470733a2f2f636f6465636f762e696f2f67682f696e6e6d696e642f786d6c2f6272616e63682f646576656c6f702f67726170682f62616467652e737667)](https://codecov.io/gh/innmind/xml)[![Type Coverage](https://camo.githubusercontent.com/f4b08477494e6c5b3176330c4fda37f2e21bf0d858c9848baeff964d06ddce7d/68747470733a2f2f73686570686572642e6465762f6769746875622f696e6e6d696e642f786d6c2f636f7665726167652e737667)](https://shepherd.dev/github/innmind/xml)

This library is an abstraction on top of the `\DOM*` classes of php, the goal is to clarify the interfaces of each node.

The big differences are that each node is immutable and is only aware of its children (instead of being aware of its parent and siblings). This can allow you to extract a whole subtree and use it to build a new tree without affecting the original one.

**Important**: you must use [`vimeo/psalm`](https://packagist.org/packages/vimeo/psalm) to make sure you use this library correctly.

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

[](#installation)

```
composer require innmind/xml
```

Usage
-----

[](#usage)

```
use Innmind\Xml\{
    Reader,
    Node,
    Element,
    Document,
};
use Innmind\Filesystem\File\Content;
use Innmind\Immutable\Attempt;

$read = Reader::of();

$tree = $read(
    Content::ofString('')
); // Attempt
```

Extract informations out of a node
----------------------------------

[](#extract-informations-out-of-a-node)

The library use the visitor pattern to give access back to the raw xml library. For example you can access the parent of a node like this:

```
use Innmind\Xml\Visitor\ParentNode;

$parent = ParentNode::of($childNode)($treeToSearchIn); // Maybe
```

Here is the full list of visitors you have access to by default:

- [`NextSibling`](src/Visitor/NextSibling.php)
- [`PreviousSibling`](src/Visitor/PreviousSibling.php)
- [`ParentNode`](src/Visitor/ParentNode.php)
- [`Text`](src/Visitor/Text.php)

###  Health Score

60

—

FairBetter than 99% of packages

Maintenance88

Actively maintained with recent releases

Popularity28

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity91

Battle-tested with a long release history

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

Recently: every ~220 days

Total

22

Last Release

60d ago

Major Versions

4.3.0 → 5.0.02019-01-05

5.0.0 → 6.0.02020-01-24

6.1.0 → 7.0.02022-04-23

7.7.0 → 8.0.02025-06-01

8.0.0 → 9.0.02026-01-25

PHP version history (8 changes)1.0.0PHP ~7.0

3.0.0PHP ~7.1

4.2.0PHP ~7.2

6.0.0PHP ~7.4

6.1.0PHP ~7.4|~8.0

7.0.0PHP ~8.1

7.5.0PHP ~8.2

9.0.0PHP ~8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/851425?v=4)[Baptiste Langlade](/maintainers/Baptouuuu)[@Baptouuuu](https://github.com/Baptouuuu)

---

Top Contributors

[![Baptouuuu](https://avatars.githubusercontent.com/u/851425?v=4)](https://github.com/Baptouuuu "Baptouuuu (281 commits)")

---

Tags

xml

### Embed Badge

![Health badge](/badges/innmind-xml/health.svg)

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

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[jms/serializer

Library for (de-)serializing data of any complexity; supports XML, and JSON.

2.3k135.8M851](/packages/jms-serializer)[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)[sabre/xml

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

52832.2M131](/packages/sabre-xml)

PHPackages © 2026

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