PHPackages                             mima/dom-navigator - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. mima/dom-navigator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mima/dom-navigator
==================

Simple wrapper for find elements in DOMNode. Adds XPath, Selector (like jQuery) mechanism to find elements, allow create own implementation.

v1.0.2(9y ago)0261MITPHPPHP &gt;=5.4

Since Mar 2Pushed 9y ago1 watchersCompare

[ Source](https://github.com/MimaTomis/dom-navigator)[ Packagist](https://packagist.org/packages/mima/dom-navigator)[ RSS](/packages/mima-dom-navigator/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (3)Dependencies (1)Versions (5)Used By (0)

PHP DOMNavigator
================

[](#php-domnavigator)

[![Build Status](https://camo.githubusercontent.com/92b8572709f04c5a142a4e1669f4ff912e28d72f278f22ec7cc1fbce94d09307/68747470733a2f2f7472617669732d63692e6f72672f4d696d61546f6d69732f646f6d2d6e6176696761746f722e737667)](https://travis-ci.org/MimaTomis/dom-navigator)

About library
-------------

[](#about-library)

The library is a wrapper for the implementation of DOM in php. Designed for easy loading html document, parse it. It allows you to implement your own algorithm search elements.

Documentation
-------------

[](#documentation)

- [Installation](#installation)
- [Use Navigator](#use-navigator)
- [Create custom Finder](#create-custom-finder)
- [Create custom Loader](#create-custom-loader)
- [Use CompositeLoader](#use-compositeloader)

### Installation

[](#installation)

Run command:

```
composer require mima/dom-navigator

```

Add dependency on your composer.json:

```
{
    "require": {
        "mima/dom-navigator": "@stable"
    }
}
```

### Use Navigator

[](#use-navigator)

For beginning usage navigator need create an instance of `DOMNavigator\Navigator` class:

```
use DOMNavigator\Navigator;
use DOMNavigator\Loader\StringLoader;
use DOMNavigator\Finder\XPathFinder;

$loader = new StringLoader();
$finder = new XPathFinder();

$navigator = new Navigator($loader, $finder);
```

Before search in document need load document:

```
// For load HTML document call:
$navigator->loadHTML($htmlContent);

// or call next method for load XML document:
$navigator->loadXML($xmlContent);
```

When you call method `loadHTML` or `loadXML`, navigator try to load `DOMDocument` with help `DOMNavigator\Loader\StringLoader` (in this example). After loading you may use navigate method for search elements in document.

```
// return \DOMNodeList with list of found elements
$addressNodes = $navigator->navigate("//div[@id='address']");
```

Navigate method always return \\DOMNodeList. It is possible to search in the context of an element:

```
// $addresNodes is a list of element from previous example
$cityNodes = $navigator->navigate("*[@id='city']", $addressNodes->item(0));
```

If you want find out number of found elements, follow to this example:

```
if ($cityNodes->length > 0) {
    ...
}
```

### Create custom Finder

[](#create-custom-finder)

All finders need implement interface `DOMNavigator\Finder\FinderInterface`.

### Create custom Loader

[](#create-custom-loader)

All loaders need implement `DOMNavigator\Finder\LoaderInterface`.

### Use CompositeLoader

[](#use-compositeloader)

If you are not sure of the source through the document, you can use CompositeLoader:

```
use DOMNavigator\Loader\CompositeLoader;
use DOMNavigator\Loader\URLLoader;
use DOMNavigator\Loader\FileLoader;
use DOMNavigator\Loader\StringLoader;

$stringLoader = new StringLoader();
$urlLoader = new URLLoader($stringLoader);
$fileLoader = new FileLoader();

// set loaders with construct
$compositeLoader = new CompositeLoader([$stringLoader, $urlLoader]);

// set loader with method
$compositeLoader->addLoader($fileLoader);
```

The next step is assigning the loader in the navigator:

```
// as first argument in constructor
$navigator = new Navigator($compositeLoader, $finder);

// or using a special method
$navigator->setLoader($compositeLoader);
```

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity61

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

Total

3

Last Release

3583d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/715813?v=4)[Mima Tomis](/maintainers/MimaTomis)[@MimaTomis](https://github.com/MimaTomis)

---

Top Contributors

[![MimaTomis](https://avatars.githubusercontent.com/u/715813?v=4)](https://github.com/MimaTomis "MimaTomis (24 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mima-dom-navigator/health.svg)

```
[![Health](https://phpackages.com/badges/mima-dom-navigator/health.svg)](https://phpackages.com/packages/mima-dom-navigator)
```

###  Alternatives

[wavey/sweetalert

SweetAlert2 implementation for Laravel

497.8k](/packages/wavey-sweetalert)[tarfin-labs/event-machine

Event-driven state machines for Laravel with event sourcing, type-safe context, and full audit trail.

199.1k](/packages/tarfin-labs-event-machine)

PHPackages © 2026

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