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

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

natlibfi/finna-xml
==================

Yet another XML parser, reader and writer for diverse records with and without namespaces.

1.6.0(3mo ago)01.7k↓27.7%MITPHPPHP &gt;=8.2CI passing

Since Jan 8Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/NatLibFi/finna-xml)[ Packagist](https://packagist.org/packages/natlibfi/finna-xml)[ RSS](/packages/natlibfi-finna-xml/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (7)Versions (11)Used By (0)

Finna-XML
=========

[](#finna-xml)

Introduction
------------

[](#introduction)

Finna-XML is yet another XML handling library for PHP. It's based on PHP's XMLReader and XMLWriter. The resulting array format is inspired by [sabre-xml](https://sabre.io/xml/).

The main goals for the library are:

- To make it easy to extract information from repeated XML elements.
- To make it easy to manage multiple namespaces and records that are missing namespace definitions.
- To do things quickly for a large number of XML records. Data structure is just a collection of associative arrays avoiding overhead of working with objects (though it makes some things more cumbersome).
- To make it possible to serialize and unserialize the parsed array without loss of information.

Features
--------

[](#features)

- Parse XML regardless of namespaces.
- Find contents in XML easily even when using multiple namespace.
- Render the XML as string (simple cases also with namespace added where missing).
- Serialize/unserialize the parsed structure for caching or other re-use.

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

[](#installation)

The recommended method for incorporating this library into your project is to use Composer ():

`composer require natlibfi/finna-xml`

Usage
-----

[](#usage)

All queries for the document contents are done with paths. Even immediate children of a node can be retrieved with a path. While the path queries resemble XPath, Finna-XML does not support any actual XPath features. All queries are relative to the starting node (or root node, if omitted), and there is currently no support for attribute filtering etc. This allows the queries to be as quick as possible.

If you need proper XPath support, use something else. :)

The following notations are supported for searching element and attribute names:

Clark notation: `{namespace-uri}localName`

This notation is used internally and required when there are namespaces in multi-level path queries.

Note that if you have a variable for a namespace URI (which you usually should), you'll need to take PHP's use of curly brackets into account in string interpolation. So if you use double quotes, also double the brackets: `$xmlDoc->all($node, "{{$namespaceUri}}element")`.

Space notation: `namespace-url localName`

This notation can be used for a single-level path query.

Examples
--------

[](#examples)

See the examples directory for simple examples, and tests in tests/NatLibFiTest/FinnaXml/XmlDocTest.php for more comprehensive examples.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance80

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

Total

10

Last Release

104d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7b63d79061b3a5c794537ffc54c9b48aa211e8a178587de939d2511fe7bc7813?d=identicon)[eremaijala](/maintainers/eremaijala)

---

Top Contributors

[![EreMaijala](https://avatars.githubusercontent.com/u/1327659?v=4)](https://github.com/EreMaijala "EreMaijala (32 commits)")

---

Tags

xmlparserdom

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[paquettg/php-html-parser

An HTML DOM parser. It allows you to manipulate HTML. Find tags on an HTML page with selectors just like jQuery.

2.4k7.9M123](/packages/paquettg-php-html-parser)[sunra/php-simple-html-dom-parser

Composer adaptation of: A HTML DOM parser written in PHP5+ let you manipulate HTML in a very easy way! Require PHP 5+. Supports invalid HTML. Find tags on an HTML page with selectors just like jQuery. Extract contents from HTML in a single line.

1.3k9.4M61](/packages/sunra-php-simple-html-dom-parser)[imangazaliev/didom

Simple and fast HTML parser

2.2k2.3M64](/packages/imangazaliev-didom)[sabre/xml

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

52832.2M131](/packages/sabre-xml)[orchestra/parser

XML Document Parser for Laravel and PHP

4581.7M5](/packages/orchestra-parser)

PHPackages © 2026

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