PHPackages                             arthurkushman/query-path - 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. arthurkushman/query-path

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

arthurkushman/query-path
========================

HTML/XML querying (CSS 4 or XPath) and processing (like jQuery)

3.1.4(4y ago)31.2M↑39.9%4[2 PRs](https://github.com/arthurkushman/querypath/pulls)MITPHPPHP &gt;=7.1

Since Feb 3Pushed 3y ago2 watchersCompare

[ Source](https://github.com/arthurkushman/querypath)[ Packagist](https://packagist.org/packages/arthurkushman/query-path)[ Docs](https://github.com/arthurkushman/querypath)[ RSS](/packages/arthurkushman-query-path/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (4)Versions (20)Used By (0)

QueryPath: Find the better way
==============================

[](#querypath-find-the-better-way)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/fef766881e71ca1e20b8f0ff0215ed31e25fa386548db6b3a91de6857823dd26/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6172746875726b7573686d616e2f7175657279706174682f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/arthurkushman/querypath/?branch=master)[![Build Status](https://camo.githubusercontent.com/91b642f8d5e18a47fd1b7248b10d4c9e64c29ef7a810f051154951fe94c275bd/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6172746875726b7573686d616e2f7175657279706174682f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/arthurkushman/querypath/build-status/master)[![Code Intelligence Status](https://camo.githubusercontent.com/66346525299ab81f0cfbdd1280a8112b7a5ce46ba1f402763598d1d03896fd1f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6172746875726b7573686d616e2f7175657279706174682f6261646765732f636f64652d696e74656c6c6967656e63652e7376673f623d6d6173746572)](https://scrutinizer-ci.com/code-intelligence)[![codecov](https://camo.githubusercontent.com/1ec54e98df521ef62fc105a5749be01d311fa9076a0d6b59a771a296d37388c3/68747470733a2f2f636f6465636f762e696f2f67682f6172746875726b7573686d616e2f7175657279706174682f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/arthurkushman/querypath)[![License: MIT](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)](https://opensource.org/licenses/MIT)

At A Glance
-----------

[](#at-a-glance)

QueryPath is a jQuery-like library for working with XML and HTML documents in PHP. It now contains support for HTML5 via the [HTML5-PHP project](https://github.com/Masterminds/html5-php).

### Why this lib was forked and recoded

[](#why-this-lib-was-forked-and-recoded)

- Legacy code (repo was left for &gt; 3 years) didn't allow to support new features of PHP&gt;=7.1
- A lot of DeaDBeaF code like: unused params, unused local variables etc
- A lot of needless flow structures
- DRY/KISS/SOLID rules were thrown away when it was developed
- Minor bugs and fragile functionality

### Installation

[](#installation)

```
composer require arthurkushman/query-path

```

### Gettings Started

[](#gettings-started)

Assuming you have successfully installed QueryPath via Composer, you can parse documents like this:

```
// HTML5 (new)
$qp = html5qp("path/to/file.html");

// Legacy HTML via libxml
$qp = htmlqp("path/to/file.html");

// XML or XHTML
$qp = qp("path/to/file.html");

// All of the above can take string markup instead of a file name:
$qp = qp("")

```

But the real power comes from chaining. Check out the example below.

### Example Usage

[](#example-usage)

Say we have a document like this:

```

    onetwothree

    fourfivesix

```

And say that the above is stored in the variable `$xml`. Now we can use QueryPath like this:

```

  *APPLE*
  *ORANGE*

```

### formatAttr()

[](#formatattr)

```
\QueryPath\DOMQuery formatAttr(string $name, callable $callback [, mixed $args [, $... ]])
```

A quick example:

```

```

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 80.9% 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 ~247 days

Recently: every ~333 days

Total

16

Last Release

1512d ago

Major Versions

2.1.2 → 3.0.0-alpha12012-06-01

PHP version history (3 changes)2.1.2PHP &gt;=5.2.0

3.0.0-alpha1PHP &gt;=5.3.0

3.1.0PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/1f7457ca41f3ffc690f41a6035fdeb4ab8eced3871a3061a638fd8dc80343588?d=identicon)[arthurkushman](/maintainers/arthurkushman)

---

Top Contributors

[![technosophos](https://avatars.githubusercontent.com/u/89193?v=4)](https://github.com/technosophos "technosophos (356 commits)")[![arthurkushman](https://avatars.githubusercontent.com/u/2669610?v=4)](https://github.com/arthurkushman "arthurkushman (41 commits)")[![eabrand](https://avatars.githubusercontent.com/u/295040?v=4)](https://github.com/eabrand "eabrand (16 commits)")[![noisan](https://avatars.githubusercontent.com/u/5478214?v=4)](https://github.com/noisan "noisan (6 commits)")[![TomorrowToday](https://avatars.githubusercontent.com/u/885108?v=4)](https://github.com/TomorrowToday "TomorrowToday (6 commits)")[![hakre](https://avatars.githubusercontent.com/u/378849?v=4)](https://github.com/hakre "hakre (3 commits)")[![sandeepshetty](https://avatars.githubusercontent.com/u/20508?v=4)](https://github.com/sandeepshetty "sandeepshetty (3 commits)")[![GDmac](https://avatars.githubusercontent.com/u/156334?v=4)](https://github.com/GDmac "GDmac (2 commits)")[![Zemistr](https://avatars.githubusercontent.com/u/2613208?v=4)](https://github.com/Zemistr "Zemistr (1 commits)")[![danielbachhuber](https://avatars.githubusercontent.com/u/36432?v=4)](https://github.com/danielbachhuber "danielbachhuber (1 commits)")[![Faryshta](https://avatars.githubusercontent.com/u/2029247?v=4)](https://github.com/Faryshta "Faryshta (1 commits)")[![fiveminuteargument](https://avatars.githubusercontent.com/u/120135?v=4)](https://github.com/fiveminuteargument "fiveminuteargument (1 commits)")[![mattfarina](https://avatars.githubusercontent.com/u/62991?v=4)](https://github.com/mattfarina "mattfarina (1 commits)")[![yaph](https://avatars.githubusercontent.com/u/60051?v=4)](https://github.com/yaph "yaph (1 commits)")[![zackkatz](https://avatars.githubusercontent.com/u/870979?v=4)](https://github.com/zackkatz "zackkatz (1 commits)")

---

Tags

csscss3html5php7queryquerypathselectorsxmlcsshtmljqueryPHP7xslt

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/arthurkushman-query-path/health.svg)

```
[![Health](https://phpackages.com/badges/arthurkushman-query-path/health.svg)](https://phpackages.com/packages/arthurkushman-query-path)
```

###  Alternatives

[querypath/querypath

HTML/XML querying and processing (like jQuery)

8197.0M27](/packages/querypath-querypath)[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[gravitypdf/querypath

PHP library for HTML(5)/XML querying (CSS 4 or XPath) and processing (like jQuery) with PHP 7.1 to 8.5 support

281.2M1](/packages/gravitypdf-querypath)[rct567/dom-query

DomQuery is a PHP library that allows easy 'jQuery like' DOM traversing and manipulation

134261.0k4](/packages/rct567-dom-query)[hexydec/htmldoc

A token based HTML document parser and minifier. Minify HTML documents including inline CSS, Javascript, and SVG's on the fly. Extract document text, attributes, and fragments. Full test suite.

2610.3k3](/packages/hexydec-htmldoc)[machy8/xhtml-formatter

Simple, lightweight, customizable (X)HTML and XML formatter / beautifier.

13181.6k7](/packages/machy8-xhtml-formatter)

PHPackages © 2026

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