\

Namespaces

QueryPath

Classes

QueryPath

Functions

html5qp()

html5qp(  $document = NULL, string  $selector = NULL, array  $options = array()) : \QueryPath\DOMQuery

Parse HTML5 documents.

This uses HTML5-PHP to parse the document. In actuality, this parser does a fine job with pre-HTML5 documents in most cases, though really old HTML (like 2.0) may have some substantial quirks.

Supported Options Any options supported by HTML5-PHP are allowed here. Additionally, the following options have meaning to QueryPath.

  • QueryPath_class

Parameters

$document
string $selector

A CSS3 selector.

array $options

An associative array of options, which is passed on into HTML5-PHP. Note that the standard QueryPath options may be ignored for this function, since it uses a different parser.

Returns

\QueryPath\DOMQuery

htmlqp()

htmlqp(  $document = NULL,   $selector = NULL,   $options = array()) 

A special-purpose version of {@link qp()} designed specifically for HTML.

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:

  • ignore_parser_warnings: TRUE
  • convert_to_encoding: ISO-8859-1 (the best for the HTML parser).
  • convert_from_encoding: auto (autodetect encoding)
  • use_parser: html

Parser warning messages are also suppressed, so if the parser emits a warning, the application will not be notified. This is equivalent to calling @code@qp()@endcode.

Warning: Character set conversions will only work if the Multi-Byte (mb) library is installed and enabled. This is usually enabled, but not always.

Parameters

$document
$selector
$options

qp()

qp(mixed  $document = NULL, string  $string = NULL, array  $options = array()) : \QueryPath\DOMQuery

Build a new Query Path.

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:

Parameters

mixed $document

A document in one of the forms listed above.

string $string

A CSS 3 selector.

array $options

An associative array of options. Currently supported options are listed above.

Returns

\QueryPath\DOMQuery

Or possibly another QueryPath-like object if you overrode QueryPath_class.