\QueryPath

Summary

Methods
Properties
Constants
with()
withXML()
withHTML()
withHTML5()
enable()
enabledExtensions()
encodeDataURL()
No public properties found
VERSION
VERSION_MAJOR
HTML_STUB
HTML5_STUB
XHTML_STUB
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Constants

VERSION

VERSION

The version string for this version of QueryPath.

Standard releases will be of the following form: .[.][-STABILITY].

Examples:

  • 2.0
  • 2.1.1
  • 2.0-alpha1

Developer releases will always be of the form dev-.

VERSION_MAJOR

VERSION_MAJOR

Major version number.

Examples:

  • 3
  • 4

HTML_STUB

HTML_STUB

This is a stub HTML 4.01 document.

Using QueryPath::XHTML_STUB is preferred.

This is primarily for generating legacy HTML content. Modern web applications should use QueryPath::XHTML_STUB.

Use this stub with the HTML familiy of methods (QueryPath::Query::html(), QueryPath::Query::writeHTML(), QueryPath::Query::innerHTML()).

HTML5_STUB

HTML5_STUB

XHTML_STUB

XHTML_STUB

This is a stub XHTML document.

Since XHTML is an XML format, you should use XML functions with this document fragment. For example, you should use \xml(), \innerXML(), and \writeXML().

This can be passed into qp() to begin a new basic HTML document.

Example:

Methods

with()

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

Parameters

$document
$selector
$options

withXML()

withXML(  $source = NULL,   $selector = NULL,   $options = array()) 

Parameters

$source
$selector
$options

withHTML()

withHTML(  $source = NULL,   $selector = NULL,   $options = array()) 

Parameters

$source
$selector
$options

withHTML5()

withHTML5(mixed  $source = NULL, string  $selector = NULL, array  $options = array()) : \QueryPath

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

mixed $source

A document as an HTML string, or a path/URL. For compatibility with existing functions, a DOMDocument, SimpleXMLElement, DOMNode or array of DOMNodes will be passed through as well. However, these types are not validated in any way.

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

enable()

enable(mixed  $extensionNames) 

Enable one or more extensions.

Extensions provide additional features to QueryPath. To enable and extension, you can use this method.

In this example, we enable the QPTPL extension:

Parameters

mixed $extensionNames

The name of an extension or an array of extension names. QueryPath assumes that these are extension class names, and attempts to register these as QueryPath extensions.

enabledExtensions()

enabledExtensions() : array

Get a list of all of the enabled extensions.

This example dumps a list of extensions to standard output:

Returns

array —

An array of extension names.

encodeDataURL()

encodeDataURL(mixed  $data, string  $mime = 'application/octet-stream', resource  $context = NULL) : \An

A static function for transforming data into a Data URL.

This can be used to create Data URLs for injection into CSS, JavaScript, or other non-XML/HTML content. If you are working with QP objects, you may want to use dataURL() instead.

Parameters

mixed $data

The contents to inject as the data. The value can be any one of the following:

  • A URL: If this is given, then the subsystem will read the content from that URL. THIS MUST BE A FULL URL, not a relative path.
  • A string of data: If this is given, then the subsystem will encode the string.
  • A stream or file handle: If this is given, the stream's contents will be encoded and inserted as data. (Note that we make the assumption here that you would never want to set data to be a URL. If this is an incorrect assumption, file a bug.)
string $mime

The MIME type of the document.

resource $context

A valid context. Use this only if you need to pass a stream context. This is only necessary if $data is a URL. (See {@link stream_context_create()}).

Returns

\An —

encoded data URL.