The above would print (formatted for readability):
Discovering the Library
To gain familiarity with QueryPath, the following three API docs are
the best to start with:
- qp(): This function constructs new queries, and is the starting point
for manipulating a document. htmlqp() is an alias tuned for HTML
documents (especially old HTML), and QueryPath::with(), QueryPath::withXML()
and QueryPath::withHTML() all perform a similar role, but in a purely
object oriented way.
- QueryPath: This is the top-level class for the library. It defines the
main factories and some useful functions.
- QueryPath::Query: This defines all of the functions in QueryPath. When
working with HTML and XML, the QueryPath::DOMQuery is the actual
implementation that you work with.
Included with the source code for QueryPath is a complete set of unit tests
as well as some example files. Those are good resources for learning about
how to apply QueryPath's tools. The full API documentation can be generated
from these files using Doxygen, or you can view it online at
If you are interested in building extensions for QueryPath, see the
QueryPath and QueryPath::Extension classes. There you will find information on adding
your own tools to QueryPath.
QueryPath also comes with a full CSS 3 selector implementation (now
with partial support for the current draft of the CSS 4 selector spec). If
you are interested in reusing that in other code, you will want to start
with QueryPath::CSS::EventHandler.php, which is the event interface for the parser.
All of the code in QueryPath is licensed under an MIT-style license
license. All of the code is Copyright, 2012 by Matt Butcher.