PHPackages                             h0gar/xpath - 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. h0gar/xpath

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

h0gar/xpath
===========

0.1.4(10y ago)51.5k23MITPHP

Since Sep 5Pushed 9y ago1 watchersCompare

[ Source](https://github.com/h0gar/xpath)[ Packagist](https://packagist.org/packages/h0gar/xpath)[ RSS](/packages/h0gar-xpath/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (5)DependenciesVersions (6)Used By (3)

\#Xpath

[![Build Status](https://camo.githubusercontent.com/6965aa8f37b0f9747f50e147d6cd8bfcbe5ecf80e34027f27a6ce9f7975edabe/68747470733a2f2f7472617669732d63692e6f72672f68306761722f78706174682e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/h0gar/xpath)

A lightweight package for xpath manipulations.

- [Installation](#installation)
- [Usage](#usage)
- [Access a node](#access-a-node)
- [Access multiple nodes](#access-multiple-nodes)
- [Navigation](#navigation)
- [Get a node inner html](#inner-html)
- [Get a node inner text](#inner-text)
- [Get an attribute](#attribute)
- [\\DOMElement and \\DOMXpath](#domelement-domxpath)

\##Installation

```
composer require h0gar/xpath *

```

\##Usage

**HTML**

```
$html = file_get_contents('page.html');
$doc = new \H0gar\Xpath\Doc($html, 'html');

```

**XML**

```
$xml = file_get_contents('page.xml');
$doc = new \H0gar\Xpath\Doc($xml, 'xml');

```

\##Access a node

```
$item = $doc->item('/html/body/div[1]/div/div[2]/ul/li[0]');
#or
$item = $doc->item('/html/body/div[1]')->item('div/div[2]/ul/li', 1);

```

\##Access multiple nodes

```
$items = $doc->items('/html/body/div[1]/div/div[2]/ul/li');
foreach($items as $item)
	//...

```

\##Navigation

```
$next = $item->next();
$prev = $item->prev();
$parent = $item->parent();

```

\##Get a node inner html

```
$html = $item->html();
#or
$html = $doc->html('/html/body/div[1]/div/div[2]/ul/li[0]');
#or
$html = $doc->html('/html/body/div[1]/div/div[2]/ul/li', 1);

```

\##Get a node inner text

```
$text = $item->text();
#or
$text = $doc->text('/html/body/div[1]/div/div[2]/ul/li[0]');
#or
$text = $doc->text('/html/body/div[1]/div/div[2]/ul/li', 1);

```

\##Get an attribute

```
$href = $item->attr('href');

```

\##\\DOMElement and \\DOMXpath

```
$domelement = $item->getNode();
$domxpath = $item->getXpath();

```

\##Contributing

Please submit all issues and pull requests to the [h0gar/xpath](http://github.com/h0gar/xpath) repository.

\##License

Open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.2% 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 ~121 days

Total

5

Last Release

3784d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/849017ae3ff0c90a272e935f9c1db9a64692db4a2a18a8d0e4bf9dbcd6f74e2c?d=identicon)[leyou](/maintainers/leyou)

---

Top Contributors

[![h0gar](https://avatars.githubusercontent.com/u/439138?v=4)](https://github.com/h0gar "h0gar (25 commits)")[![ckdarby](https://avatars.githubusercontent.com/u/220283?v=4)](https://github.com/ckdarby "ckdarby (1 commits)")

### Embed Badge

![Health badge](/badges/h0gar-xpath/health.svg)

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

###  Alternatives

[hyperthese/php-serial

Multi-platform serial port access convenience class

3557.7k1](/packages/hyperthese-php-serial)

PHPackages © 2026

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