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

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

digitalkaoz/xml-filter
======================

filter data out of xml documents

1.0(9y ago)316MITPHPPHP &gt;=7.0

Since Oct 2Pushed 9y ago1 watchersCompare

[ Source](https://github.com/digitalkaoz/xml-filter)[ Packagist](https://packagist.org/packages/digitalkaoz/xml-filter)[ RSS](/packages/digitalkaoz-xml-filter/feed)WikiDiscussions master Synced 4w ago

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

XmlFilter
=========

[](#xmlfilter)

this library lets you filter complex Data-Structures out of XML Documents into some Array Structure (nested Arrays, Maps, Strings ...).

- It is capable of using different XML Backends (`\SimpleXml*` or `\Dom*` or even your Own)
- It has Support for Type-Casting, Sorting, Validation, Reference-Checking, Conditional-Inclusion, Post-Processing, Merging, Aggregating and ...
- It is extendable (it uses Pimple behind the curtain), so you can provide your own Filter, or override nearly every part

[![Build Status](https://camo.githubusercontent.com/9ca30ce78584ba0f774b9b8d21788ffc98e3aaa66eaeeee17a9808227ad31af7/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6469676974616c6b616f7a2f786d6c2d66696c7465722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/digitalkaoz/xml-filter)[![Dependency Status](https://camo.githubusercontent.com/354bc0de7c36ebc21d70001bf492535cf4be50b9c32edc4b3ee2d1c48d877842/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3537393064653430393961343035303030643264366365382f62616467652e7376673f7374796c653d666c61742d737175617265)](https://www.versioneye.com/user/projects/5790de4099a405000d2d6ce8)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/40933f4d27f2de13e0cefeaae7ba49ffac42ee2aa52fdf3bf29f6380f9058207/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6469676974616c6b616f7a2f786d6c2d66696c7465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/digitalkaoz/xml-filter/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/b3261225cf54789dc602bb636648991a0e9fb2d395df8fec3a31da02f6232f9e/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6469676974616c6b616f7a2f786d6c2d66696c7465722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/digitalkaoz/xml-filter/?branch=master)[![SensioLabsInsight](https://camo.githubusercontent.com/0802db59c80c927d7f8735d3379434269bd0aa76311c9b02ad3fd25e2b4f9f87/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f31643331663031342d646262642d346334312d613634642d6134653431636466613361332e7376673f7374796c653d666c61742d737175617265)](https://insight.sensiolabs.com/projects/1d31f014-dbbd-4c41-a64d-a4e41cdfa3a3)[![Latest Stable Version](https://camo.githubusercontent.com/5fda8c3f6a488b462b01317c4b138c8cb960b0eb71b4853f60a76ead94f0a895/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6469676974616c6b616f7a2f786d6c2d66696c7465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/digitalkaoz/xml-filter)[![Total Downloads](https://camo.githubusercontent.com/95bc666dbbbe74e6d2a0e275286f2605c3cf408933b4943c36bdc6162648514c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6469676974616c6b616f7a2f786d6c2d66696c7465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/digitalkaoz/xml-filter)[![StyleCI](https://camo.githubusercontent.com/b78d32187cea24fedb462e3e82247c9e9d5f3e344df2bf66d44cd4b39dd12d4c/68747470733a2f2f7374796c6563692e696f2f7265706f732f36333334323734382f736869656c64)](https://styleci.io/repos/63342748)

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

[](#installation)

```
$ composer install

```

Example
-------

[](#example)

> Given I Have the following XML Document

```

    foo
    20
    30
    10

```

> When I use the following Configuration (while using the `Yaml` Loader)

```
Rs\XmlFilter\Filter\AggregateFilter:
    mappings:
        bazz:
            filter: Rs\XmlFilter\Filter\AggregateFilter
            mappings:
                foo: "/doc/foo"
        bar:
            path: "/doc/bar"
            cast: "int"
            sort: true
            multiple: true
```

> I want to get the following Array after filtering

```
[
    'bazz' => [
        'foo' => 'foo',
    ],
    'bar' => [10, 20, 30]
]
```

Parse a RSS Feed
----------------

[](#parse-a-rss-feed)

```
Rs\XmlFilter\Filter\MapFilter:
  basePath: //channel/item
  key: ./guid
  value:
    filter: Rs\XmlFilter\Filter\AggregateFilter
    mappings:
      title: ./title
      link: ./link
      category: ./category
      date: ./pubDate
      text:
        filter: Rs\XmlFilter\Filter\PostFilter
        callable: strip_tags
        real_filter:
          filter: Rs\XmlFilter\Filter\ScalarFilter
          path: ./description
```

```
$filter = \Rs\XmlFilter\XmlFilter::create();

$doc = $filter::load(file_get_contents('https://news.google.de/?output=rss'));
$config = new \Rs\XmlFilter\Loader\YamlLoader(__DIR__ . '/rss.yml');

$result = $filter->filter($doc, $config);

echo json_encode($result, JSON_PRETTY_PRINT);
```

Usage
-----

[](#usage)

- [Filters](./doc/filters.md)
- [Loaders](./doc/loaders.md)
- [Backends](./doc/backends.md)

PHAR
----

[](#phar)

to build a phar simply run

```
$ composer build
```

Tests
-----

[](#tests)

```
$ composer test-all

```

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Unknown

Total

1

Last Release

3558d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/293591?v=4)[Robert Schönthal](/maintainers/digitalkaoz)[@digitalkaoz](https://github.com/digitalkaoz)

---

Top Contributors

[![digitalkaoz](https://avatars.githubusercontent.com/u/293591?v=4)](https://github.com/digitalkaoz "digitalkaoz (12 commits)")

### Embed Badge

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

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.8M717](/packages/sylius-sylius)[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.8M465](/packages/pimcore-pimcore)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M196](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.1k16.8k](/packages/prestashop-prestashop)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9417.2k58](/packages/open-dxp-opendxp)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6941.5M398](/packages/drupal-core-recommended)

PHPackages © 2026

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