Handler that tracks progress of a query through a DOM.
The main idea is that we keep a copy of the tree, and then use an array to keep track of matches. To handle a list of selectors (using the comma separator), we have to track both the currently progressing match and the previously matched elements.
To use this handler:
find(string $filter) : \QueryPath\CSS\QueryPathEventHandler
Generic finding method.
This is the primary searching method used throughout QueryPath.
A valid CSS 3 filter.
matches() : array
Get the results of a find() operation.
Return an array of matching items.
An array of matched values. The specific data type in the matches will differ depending on the data type searched, but in the core QueryPath implementation, this will be an array of DOMNode objects.
pseudoClass( $name, $value = NULL)
This also supports the following nonstandard pseudo classes: - :x-reset/:x-root (reset to the main item passed into the constructor. Less drastic than :root) - :odd/:even (shorthand for :nth-child(odd)/:nth-child(even))
For an element to be adjacent to another, it must be THE NEXT NODE in the node list. So if an element is surrounded by pcdata, there are no adjacent nodes. E.g. in <a/>FOO<b/>, the a and b elements are not adjacent.
In a strict DOM parser, line breaks and empty spaces are nodes. That means
nodes like this will not be adjacent:
$doc = new DomDocument();
nthChild(integer $groupSize, integer $elementInGroup, boolean $lastChild = FALSE)
Pseudo-class handler for nth-child and all related pseudo-classes.
The size of the group (in an+b, this is a).
The offset in a group. (in an+b this is b).
Whether counting should begin with the last child. By default, this is false. Pseudo-classes that start with the last-child can set this to true.
Determine what candidates are in the current scope.
This is a utility method that gets the list of elements that should be evaluated in the context. If $this->findAnyElement is TRUE, this will return a list of every element that appears in the subtree of $this->matches. Otherwise, it will just return $this->matches.