Skip to content
technosophos edited this page Aug 30, 2010 · 9 revisions

QueryPath is a PHP library resembling jQuery. It implements much of the jQuery API, but it is oriented toward server-side programming. It can be used for parsing or generating HTML and XML (including RSS, SVG, and similar formats). QueryPath can also be used to retrieve XML from web services over HTTP. The QueryPath Database layer provides tools for moving data between XML/HTML files and SQL-based databases. A plugin architecture makes it easy to extend QueryPath’s functionality.

QueryPath uses a chainable API. Following jQuery, it uses succinct and short idioms, making it easy to accomplish complex tasks in only a few lines of code. Here’s a sample of QueryPath in action:


<?php
require_once 'QueryPath/QueryPath.php';
qp('./test.html')->find('title')->text('Welcome')->writeHTML();
?>

This fragment loads the QueryPath library, and then executes a single jQuery chain. The chain opens a file, test.html, and then finds the element. The text inside of that element is then set to Welcome, and the entire document is then written to standard out (that is, it is sent to the client).

An Introduction to QueryPath will help you get started. (Or, if you want to go from jQuery to QueryPath, you may want to start with this article)

For a more visual introduction to QueryPath, there are a few videos:

Examples and Coding Tutorials

There are various examples and tutorials around the web. Here is a small list. (If you’ve written one, please submit it!)

Lists

You may wish to join one of the two QueryPath groups/lists:

Clone this wiki locally