PHPackages                             querypath/querypath - 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. querypath/querypath

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

querypath/querypath
===================

HTML/XML querying and processing (like jQuery)

3.0.5(9y ago)8197.0M↑33.7%114[57 issues](https://github.com/technosophos/querypath/issues)[11 PRs](https://github.com/technosophos/querypath/pulls)20MITPHPPHP &gt;=5.3.0

Since Feb 3Pushed 1y ago43 watchersCompare

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

READMEChangelogDependencies (1)Versions (15)Used By (20)

Use GravityPDF's QueryPath
--------------------------

[](#use-gravitypdfs-querypath)

> QueryPath is now updated and maintained by the amazing folks at GravityPDF. . The version of QueryPath in this repository is no longer maintained. You are encouraged to use [GravityPDF's version](https://github.com/GravityPDF/querypath). -- Matt, Dec. 2022

QueryPath: Find your way.
=========================

[](#querypath-find-your-way)

[![Stability: Maintenance](https://camo.githubusercontent.com/f62028424fdd88d61aba40e3fca36747f1d78f41eea8971729c377ddee0166c3/68747470733a2f2f6d61737465726d696e64732e6769746875622e696f2f73746162696c6974792f6d61696e74656e616e63652e737667)](https://masterminds.github.io/stability/maintenance.html)

Authors: Matt Butcher (lead), Emily Brand, and many others

[Website](http://querypath.org) | [API Docs](http://api.querypath.org/docs) | [VCS and Issue Tracking](http://github.com/technosophos/querypath) | [Support List](http://groups.google.com/group/support-querypath) | [Developer List](http://groups.google.com/group/devel-querypath) | [Pear channel](http://pear.querypath.org) |

This package is licensed under an MIT license (COPYING-MIT.txt).

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).

### Gettings Started

[](#gettings-started)

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

```
require_once "vendor/autoload.php";

// 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:

```
