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

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

lightools/xml
=============

Simple and safe parsing of XML and HTML sources.

v3.0.0(4y ago)10114.7k—3.8%1[1 PRs](https://github.com/lightools/xml/pulls)4MITPHPPHP &gt;=8.0CI passing

Since Mar 21Pushed 10mo ago1 watchersCompare

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

READMEChangelogDependencies (5)Versions (9)Used By (4)

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

[](#introduction)

This library provides simple interface for loading XML or HTML strings to DomDocument object. It prevents some known vulnerabilities and allows you to handle LibXML errors simply by catching XmlException as you can see below.

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

[](#installation)

```
$ composer require lightools/xml
```

Simple usage
------------

[](#simple-usage)

Both loading methods (loadXml and loadHtml) return DomDocument. If you prefer working with SimpleXmlElement, you can use [simplexml\_import\_dom](https://secure.php.net/manual/en/function.simplexml-import-dom.php) function.

```
$xml = 'text';
$html = 'Foo';

$loader = new Lightools\Xml\XmlLoader();

try {
    $xmlDomDocument = $loader->loadXml($xml);
    $htmlDomDocument = $loader->loadHtml($html);

} catch (Lightools\Xml\XmlException $e) {
    // process exception
}
```

How to run checks
-----------------

[](#how-to-run-checks)

```
$ composer check
```

Versions
--------

[](#versions)

- v1.x is for PHP 5.4 and higher
- v2.x is for PHP 7.1 and higher
- v3.x is for PHP 8.0 and higher

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 58.3% 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 ~329 days

Recently: every ~414 days

Total

7

Last Release

1735d ago

Major Versions

v1.0.x-dev → v2.0.02017-02-05

v2.0.x-dev → v3.0.02021-08-18

PHP version history (3 changes)v1.0.0PHP &gt;=5.4

v2.0.0PHP &gt;=7.1

v3.0.0PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/5b545e3f9d982d538f11bc42b3dc2d186f706cef92c8bc8bc8f8788b08186ea5?d=identicon)[janedbal](/maintainers/janedbal)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (21 commits)")[![janedbal](https://avatars.githubusercontent.com/u/1993453?v=4)](https://github.com/janedbal "janedbal (15 commits)")

---

Tags

domdocumenthtmlxml

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

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

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[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)[meyfa/php-svg

Read, edit, write, and render SVG files with PHP

54613.9M42](/packages/meyfa-php-svg)

PHPackages © 2026

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