PHPackages                             mindplay/easyxml - 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. mindplay/easyxml

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

mindplay/easyxml
================

XML parser with a functional approach

1.0.1(11y ago)12.5k1[1 PRs](https://github.com/mindplay-dk/easyxml/pulls)LGPL-3.0+PHPPHP &gt;=5.3.0

Since Nov 10Pushed 8y ago1 watchersCompare

[ Source](https://github.com/mindplay-dk/easyxml)[ Packagist](https://packagist.org/packages/mindplay/easyxml)[ RSS](/packages/mindplay-easyxml/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (2)Versions (4)Used By (0)

mindplay/easyxml
----------------

[](#mindplayeasyxml)

[![Build Status](https://camo.githubusercontent.com/5578ffc6746ac4ae035fbf3d6d2035b13a4cfce6adc76e11002b5e1f1f0b321b/68747470733a2f2f7472617669732d63692e6f72672f6d696e64706c61792d646b2f65617379786d6c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mindplay-dk/easyxml)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/916ebae71ade1d3ace8ee44943a8fe236f88e2eff334c63a740c936268603bb2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d696e64706c61792d646b2f65617379786d6c2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mindplay-dk/easyxml/?branch=master)

[![Code Coverage](https://camo.githubusercontent.com/3b965363751a037b8489937a1a34d23ab4f9c335d63dad0d2bfb5c66078394ff/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d696e64706c61792d646b2f65617379786d6c2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mindplay-dk/easyxml/?branch=master)

Functional XML-reader for PHP 5.3+.

A somewhat different approach to reading/parsing XML files with PHP, using a hierarchy of anonymous functions (closures) reflecting the hierarchy of the XML document itself.

This is useful when reading structured XML documents - e.g. XML documents with a predictable structure. It's probably less than enjoyable when reading unstructured documents, such as XHTML documents.

Parsing happens on-the-fly, e.g. avoiding the overhead of loading an entire document into memory and performing repetitive queries against it. This approach is memory efficient, enabling you to parse very large documents in a streaming fashion - it is not super fast (throughput ~500 KB/sec on my laptop) but XML parsing is never truly fast, so you should definitely always cache the parsed results.

Usage
-----

[](#usage)

Let's say you wish to read the following XML file:

```

```

Your reader might look something like this:

```
$doc = new Parser();

$doc['cats/cat'] = function (Visitor $cat, $name) {
    echo "a cat named: {$name}\n";

    $cat['kitten'] = function ($name) {
        echo "a kitten named: {$name}\n";
    };
};

$doc->parseFile('my_cats.xml');
```

The output would be this:

```
a cat named: whiskers
a kitten named: mittens
a cat named: tinker
a kitten named: binky

```

If it's not obvious, the path `cats/cat` designates a `` node inside a `` node.

You can also match text-nodes, e.g. a path like `foo/bar#text` will match `YO` in `YO`.

And finally, you can use `#end` to match closing tags, if needed.

Incidentally, I don't actually have cats - but if I did, you can bet those would be their names.

See "test.php" and "example/cd\_catalog.php" for more examples of how to use this.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Total

2

Last Release

4189d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9445f567f43ee7a963270651e40e533634586f959e4df3d5398d001b1cb49be8?d=identicon)[mindplay.dk](/maintainers/mindplay.dk)

---

Top Contributors

[![mindplay-dk](https://avatars.githubusercontent.com/u/103348?v=4)](https://github.com/mindplay-dk "mindplay-dk (12 commits)")

### Embed Badge

![Health badge](/badges/mindplay-easyxml/health.svg)

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

###  Alternatives

[mck89/peast

Peast is PHP library that generates AST for JavaScript code

19139.2M47](/packages/mck89-peast)[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9843.5k](/packages/sauladam-shipment-tracker)[jstewmc/rtf

Read and write Rich Text Format (RTF) documents with PHP

45153.1k6](/packages/jstewmc-rtf)[tcds-io/php-jackson

A lightweight, flexible object serializer for PHP, inspired by FasterXML/jackson

113.2k10](/packages/tcds-io-php-jackson)

PHPackages © 2026

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