The two major DOMs are the XML DOM and the HTML DOM. Using Query Path, you can build, parse, search, and modify DOM documents.
To use Query Path, this is the only file you should need to import.
Standard usage:
The above would print (formatted for readability):
To learn about the functions available to a Query Path object, see QueryPath. The qp() function is used to build new QueryPath objects. The documentation for that function explains the wealth of arguments that the function can take.
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 PHPDocumentor.
If you are interested in building extensions for QueryParser, see the QueryPathExtender class. There, you will find information on adding your own tools to QueryPath.
QueryPath also comes with a full CSS 3 selector parser implementation. If you are interested in reusing that in other code, you will want to start with CssEventHandler.php, which is the event interface for the parser.
All of the code in QueryPath is licensed under either the LGPL or an MIT-like license (you may choose which you prefer). All of the code is Copyright, 2009 by Matt Butcher.
CLASS NAME | DESCRIPTION |
| QueryPath | The Query Path object is the primary tool in this library. |
| QueryPathEntities | |
| QueryPathIterator | An iterator for QueryPath. |
| QueryPathOptions | Manage default options. |
| QueryPathException | Exception indicating that a problem has occured inside of a QueryPath object. |
| QueryPathParseException | Exception indicating that a parser has failed to parse a file. |
| QueryPathIOException | Exception indicating that a parser has failed to parse a file. |
'CssEventHandler.php' (line 79)
'QueryPathExtension.php' (line 83)
ML_EXP (line 74)
htmlqp (line 208)
XHTML (if valid) can be easily parsed by qp() with no problems. However, because of the way that libxml handles HTML, there are several common steps that need to be taken to reliably parse non-XML HTML documents. This function is a convenience tool for configuring QueryPath to parse HTML.
The following options are automatically set unless overridden:
Warning: Character set conversions will only work if the Multi-Byte (mb) library is installed and enabled. This is usually enabled, but not always.
qp (line 177)
This builds a new Query Path object. The new object can be used for reading, search, and modifying a document.
While it is permissible to directly create new instances of a QueryPath implementation, it is not advised. Instead, you should use this function as a factory.
Example:
This function is used internally by QueryPath. Anything that modifies the behavior of this function may also modify the behavior of common QueryPath methods.