Property | Type | Description | |
---|---|---|---|
$attribute_shorttag | boolean | Use short tags for attributes? If true, then attributes with values equal to the attribute name will not output the value, e.g. selected="selected" will be selected. | |
$attributes | array | Attributes of node | |
$attributes_ns | array | Namespace info for attributes | |
$childClass | string | Name of the class used for {@link addChild()} | |
$childClass_ASP | string | Name of the class used for {@link addASP()} | |
$childClass_CDATA | string | Name of the class used for {@link addCDATA()} | |
$childClass_Comment | string | Name of the class used for {@link addComment()} | |
$childClass_Conditional | string | Name of the class used for {@link addContional()} | |
$childClass_Doctype | string | Name of the class used for {@link addDoctype()} | |
$childClass_Text | string | Name of the class used for {@link addText()} | |
$childClass_XML | string | Name of the class used for {@link addXML()} | |
$children | array | Array of child nodes | |
$filter_map | array | Function map used for the selector filter | |
$parent | Parent node, null if none | ||
$parserClass | string | Name of the parser class | |
$selectClass | string | Name of the selector class | |
$self_close | boolean | Is node a self closing node? No closing tag if true. | |
$self_close_str | string | If self close, then this will be used to close the tag | |
$tag | string | Full tag name (including namespace) | |
$tag_ns | array | Namespace info for tag |
Method | Description | |
---|---|---|
__construct ( string | array $tag, |
Class constructor | |
__destruct ( ) | Class destructor | |
__get ( $attribute ) : string | Class magic get method, outputs {@link getAttribute()} | |
__invoke ( string $query = '*' ) : pQuery | Class magic invoke method, performs {@link query()}. | |
__isset ( $attribute ) : boolean | Class magic isset method, returns {@link hasAttribute()} | |
__set ( $attribute, $value ) | Class magic set method, performs {@link setAttribute()} | |
__toString ( ) : string | Class toString, outputs {@link $tag} | |
__unset ( $attribute ) | Class magic unset method, performs {@link deleteAttribute()} | |
addASP ( $tag = '', $text = '', $attributes = [], &$offset = null ) | #php5 | |
addAttribute ( string $attr, string $val ) | Add new attribute | |
addCDATA ( $text, &$offset = null ) | #php5 | |
addChild ( $tag, &$offset = null ) | #php5 | |
addClass ( string | array $className ) | Add new class(es) | |
addComment ( $text, &$offset = null ) | #php5 | |
addConditional ( $condition, $hidden = true, &$offset = null ) | #php5 | |
addDoctype ( $dtd, &$offset = null ) | #php5 | |
addText ( $text, &$offset = null ) | #php5 | |
addXML ( $tag = 'xml', $text = '', $attributes = [], &$offset = null ) | #php5 | |
after ( $content ) | ||
append ( $content ) | ||
attr ( $name, $value = null ) | ||
attributeCount ( ) : integer | Number of attributes | |
before ( $content ) | ||
changeParent ( $to, &$index = null ) | #php5 | |
childCount ( boolean $ignore_text_comments = false ) : integer | Number of children in node | |
clear ( ) | Deletes all child nodes from node | |
count ( ) | ||
delete ( ) | Delete node from parent and clear node | |
deleteAttribute ( string | integer $attr, string $compare = 'total', boolean $case_sensitive = false ) | Delete attribute(s) | |
deleteChild ( integer | |
Delete a child node | |
detach ( boolean $move_children_up = false ) | Detach node from parent | |
dumpLocation ( ) : string | Returns place in document | |
findChild ( |
Find node in children | |
firstChild ( boolean $ignore_text_comments = false ) : |
First child node | |
getAttribute ( string | integer $attr, string $compare = 'total', boolean $case_sensitive = false ) : string | array | Gets value(s) of attribute(s) | |
getAttributeNS ( string | integer $attr, string $compare = 'name', boolean $case_sensitive = false ) : string | array | Gets namespace of attribute(s) | |
getChild ( integer | |
Get childnode | |
getChildrenByAttribute ( string $attribute, string $value, string $mode = 'equals', string $compare = 'total', boolean | integer $recursive = true ) : array | Finds children that match a certain attribute | |
getChildrenByCallback ( callable $callback, boolean | integer $recursive = true, boolean $check_self = false ) : array | Finds children using a callback function | |
getChildrenByClass ( string $class, boolean | integer $recursive = true ) : array | Finds all children using class attribute | |
getChildrenByID ( string $id, boolean | integer $recursive = true ) : array | Finds all children using ID attribute | |
getChildrenByMatch ( $conditions, boolean | integer $recursive = true, boolean $check_self = false, $custom_filters = [] ) : array | Finds children using the {$link match()} function | |
getChildrenByName ( string $name, boolean | integer $recursive = true ) : array | Finds all children using name attribute | |
getChildrenByTag ( string $tag, string $compare = 'total', boolean | integer $recursive = true ) : array | Finds children that match a certain tag | |
getEncoding ( ) : string | boolean | Try to determine the encoding of the current tag | |
getInnerText ( ) : string | Similar to JavaScript innerText, will return (html formatted) content | |
getNamespace ( ) : string | Get namespace of node | |
getNextSibling ( boolean $skip_text_comments = true ) : |
Get node next to current | |
getOuterText ( ) : string | Similar to JavaScript outerText, will return full (html formatted) node | |
getPlainText ( ) : string | Similar to JavaScript plainText, will return text in node (and subnodes) | |
getPlainTextUTF8 ( ) : string | Return plaintext taking document encoding into account | |
getPreviousSibling ( boolean $skip_text_comments = true ) : |
Get node previous to current | |
getRoot ( ) : |
Get top parent | |
getSibling ( integer $offset = 1 ) : |
Get sibling node | |
getTag ( ) : string | Get tagname of node (without namespace) | |
hasAttribute ( $attr, string $compare = 'total', boolean $case_sensitive = false ) : boolean | Checks if node has attribute | |
hasChild ( |
Checks if node has another node as child | |
hasClass ( string $className ) : boolean | Determine if node has a certain class | |
hasParent ( |
Find out if node has (a certain) parent | |
html ( string | null $value = null ) : string | Return html code of node | |
indent ( ) : integer | Calculate indent of node (number of parent tags - 1) | |
index ( boolean $count_all = true ) : integer | Index of node in parent | |
insertChild ( string | |
Insert childnode | |
isComment ( ) : boolean | Find out if node is comment | |
isParent ( |
Find out if node is parent of a certain tag | |
isText ( ) : boolean | Find out if node is text | |
isTextOrComment ( ) : boolean | Find out if node is text or comment node | |
lastChild ( boolean $ignore_text_comments = false ) : |
Last child node | |
match ( $conditions, array $match = true, array $custom_filters = [] ) : boolean | Checks if node matches certain conditions | |
move ( $to, &$new_index ) | #php5 | |
moveChildren ( $to, &$new_index, $start, $end ) | #php5 | |
prepend ( $content = null ) | } | |
prop ( $name, $value = null ) | ||
query ( string $query = '*' ) : pquery\IQuery | Performs a css query on the node. | |
remove ( $selector = null ) | ||
removeAttr ( $name ) | ||
removeClass ( string | array $className ) | Remove clas(ses) | |
replaceWith ( $content ) | ||
select ( string $query = '*', integer | boolean $index = false, boolean | integer $recursive = true, boolean $check_self = false ) : |
Performs css query on node | |
setAttribute ( string | integer $attr, $val, string $compare = 'total', boolean $case_sensitive = false ) | Sets value(s) of attribute(s) | |
setAttributeNS ( string | integer $attr, string $namespace, string $compare = 'name', boolean $case_sensitive = false ) : boolean | Sets namespace of attribute(s) | |
setIndex ( integer $index ) | Change index of node in parent | |
setInnerText ( string $text, |
Similar to JavaScript innerText, will replace child nodes with new text | |
setNamespace ( string $ns ) | Set namespace of node | |
setOuterText ( string $text, |
Similar to JavaScript outerText, will replace node (and child nodes) with new text | |
setPlainText ( string $text ) | Similar to JavaScript plainText, will replace child nodes with new text (literal) | |
setTag ( string $tag, boolean $with_ns = false ) | Set tag (with or without namespace) | |
tagName ( type $value = null ) : string | |
||
text ( $value = null ) | ||
toString ( boolean $attributes = true, boolean | integer $recursive = true, boolean | integer $content_only = false ) : string | Returns the node as string | |
toggleClass ( $classname, $switch = null ) | ||
typeIndex ( ) : integer | Index of all similar nodes in parent | |
unwrap ( ) | ||
val ( $value = null ) | ||
wrap ( string | |
Wrap node | |
wrapInner ( string | |
Wrap child nodes |
Method | Description | |
---|---|---|
createNode ( string | |
Create a {@link DomNode} from its string representation. | |
createNodes ( string | |
Create an array of {@link DomNode} objects from their string representation. | |
filter_checked ( ) : boolean | Checks if a node matches css query filter ":checked" | |
filter_comment ( ) : boolean | Checks if node matches css query filter ":comment" | |
filter_contains ( string $text ) : boolean | Checks if node matches css query filter ":contains(s)" | |
filter_element ( ) : boolean | Checks if node matches css query filter ":element" | |
filter_empty ( ) : boolean | Checks if node matches css query filter ":empty" | |
filter_even ( ) : boolean | Checks if node matches css query filter ":even" | |
filter_every ( $n ) : boolean | Checks if node matches css query filter ":every(n)" | |
filter_first ( ) : boolean | Checks if node matches css query filter ":first" | |
filter_firsttype ( ) : boolean | Checks if node matches css query filter ":first-of-type" | |
filter_gt ( string $n ) : boolean | Checks if node matches css query filter ":gt(n)" | |
filter_has ( string $selector ) : boolean | Checks if node matches css query filter ":has(s)" | |
filter_hastext ( ) : boolean | Checks if node matches css query filter ":has-text" | |
filter_lang ( string $lang ) : boolean | Checks if node matches css query filter ":lang(s)" | |
filter_last ( ) : boolean | Checks if node matches css query filter ":last" | |
filter_lasttype ( ) : boolean | Checks if node matches css query filter ":last-of-type" | |
filter_lt ( string $n ) : boolean | Checks if node matches css query filter ":lt(n)" | |
filter_nchild ( string $n ) : boolean | Checks if node matches css query filter ":nth-child(n)" | |
filter_nlastchild ( string $n ) : boolean | Checks if node matches css query filter ":nth-last-child(n)" | |
filter_nlastype ( string $n ) : boolean | Checks if node matches css query filter ":nth-last-of-type(n)" | |
filter_not ( string $selector ) : boolean | Checks if node matches css query filter ":not(s)" | |
filter_notempty ( ) : boolean | Checks if node matches css query filter ":not-empty" | |
filter_notext ( ) : boolean | Checks if node matches css query filter ":no-text" | |
filter_ntype ( string $n ) : boolean | Checks if node matches css query filter ":nth-of-type(n)" | |
filter_odd ( ) : boolean | Checks if node matches css query filter ":odd" | |
filter_onlychild ( ) : boolean | Checks if node matches css query filter ":only-child" | |
filter_onlytype ( ) : boolean | Checks if node matches css query filter ":only-of-type" | |
filter_root ( ) : boolean | Checks if node matches css query filter ":root" | |
filter_selected ( ) : boolean | Checks if a node matches css query filter ":selected" | |
filter_text ( ) : boolean | Checks if node matches css query filter ":text" | |
findAttribute ( string | integer $attr, string $compare = 'total', boolean $case_sensitive = false ) : array | Find attribute using namespace, name or both | |
match_attributes ( array $attributes ) : boolean | Checks if attributes match certain conditions | |
match_filters ( $conditions, array $custom_filters = [] ) : boolean | Checks if node matches certain filters | |
match_tags ( array $tags ) : boolean | Checks if tag matches certain conditions | |
toString_attributes ( ) : string | Returns all the attributes and their values | |
toString_content ( boolean $attributes = true, boolean | integer $recursive = true, boolean $content_only = false ) : string | Returns the content of the node (child tags and text) |
public __construct ( string | array $tag, |
||
$tag | string | array | Name of the tag, or array with taginfo (array( 'tag_name' => 'tag', 'self_close' => false, 'attributes' => array('attribute' => 'value'))) |
$parent | Parent of node, null if none |
public __set ( $attribute, $value ) |
public __toString ( ) : string | ||
return | string |
public __unset ( $attribute ) |
public addASP ( $tag = '', $text = '', $attributes = [], &$offset = null ) |
public addAttribute ( string $attr, string $val ) | ||
$attr | string | |
$val | string |
public addConditional ( $condition, $hidden = true, &$offset = null ) |
public addXML ( $tag = 'xml', $text = '', $attributes = [], &$offset = null ) |
public attributeCount ( ) : integer | ||
return | integer |
public childCount ( boolean $ignore_text_comments = false ) : integer | ||
$ignore_text_comments | boolean | Ignore text/comments with calculation |
return | integer |
protected createNode ( string | |
||
$content | string | |
|
return |
protected createNodes ( string | |
||
$content | string | |
|
return |
public deleteChild ( integer | |
||
$child | integer | |
Child(index) to delete, negative to count from end |
$soft_delete | boolean | False to call {@link delete()} from child |
public dumpLocation ( ) : string | ||
return | string |
protected filter_checked ( ) : boolean | ||
return | boolean |
protected filter_comment ( ) : boolean | ||
return | boolean |
protected filter_contains ( string $text ) : boolean | ||
$text | string | |
return | boolean |
protected filter_element ( ) : boolean | ||
return | boolean |
protected filter_empty ( ) : boolean | ||
return | boolean |
protected filter_even ( ) : boolean | ||
return | boolean |
protected filter_every ( $n ) : boolean | ||
return | boolean |
protected filter_first ( ) : boolean | ||
return | boolean |
protected filter_firsttype ( ) : boolean | ||
return | boolean |
protected filter_has ( string $selector ) : boolean | ||
$selector | string | |
return | boolean |
protected filter_hastext ( ) : boolean | ||
return | boolean |
protected filter_lang ( string $lang ) : boolean | ||
$lang | string | |
return | boolean |
protected filter_last ( ) : boolean | ||
return | boolean |
protected filter_lasttype ( ) : boolean | ||
return | boolean |
protected filter_nchild ( string $n ) : boolean | ||
$n | string | 1-based index |
return | boolean |
protected filter_nlastchild ( string $n ) : boolean | ||
$n | string | 1-based index |
return | boolean |
protected filter_nlastype ( string $n ) : boolean | ||
$n | string | 1-based index |
return | boolean |
protected filter_not ( string $selector ) : boolean | ||
$selector | string | |
return | boolean |
protected filter_notempty ( ) : boolean | ||
return | boolean |
protected filter_notext ( ) : boolean | ||
return | boolean |
protected filter_ntype ( string $n ) : boolean | ||
$n | string | 1-based index |
return | boolean |
protected filter_odd ( ) : boolean | ||
return | boolean |
protected filter_onlychild ( ) : boolean | ||
return | boolean |
protected filter_onlytype ( ) : boolean | ||
return | boolean |
protected filter_root ( ) : boolean | ||
return | boolean |
protected filter_selected ( ) : boolean | ||
return | boolean |
protected filter_text ( ) : boolean | ||
return | boolean |
protected findAttribute ( string | integer $attr, string $compare = 'total', boolean $case_sensitive = false ) : array | ||
$attr | string | integer | Negative int to count from end |
$compare | string | "namespace", "name" or "total" |
$case_sensitive | boolean | Compare with case sensitivity |
return | array | array('ns', 'attr', 'ns:attr', index) |
public firstChild ( boolean $ignore_text_comments = false ) : |
||
$ignore_text_comments | boolean | Ignore text/comments with index calculation |
return |
public getAttribute ( string | integer $attr, string $compare = 'total', boolean $case_sensitive = false ) : string | array | ||
$attr | string | integer | Negative int to count from end |
$compare | string | Find node using "namespace", "name" or "total" |
$case_sensitive | boolean | Compare with case sensitivity |
return | string | array |
public getAttributeNS ( string | integer $attr, string $compare = 'name', boolean $case_sensitive = false ) : string | array | ||
$attr | string | integer | Negative int to count from end |
$compare | string | Find node using "namespace", "name" or "total" |
$case_sensitive | boolean | Compare with case sensitivity |
return | string | array | False if not found |
public getChildrenByAttribute ( string $attribute, string $value, string $mode = 'equals', string $compare = 'total', boolean | integer $recursive = true ) : array | ||
$attribute | string | |
$value | string | |
$mode | string | Compare mode, "equals", "|=", "contains_regex", etc. |
$compare | string | "total"/"namespace"/"name" |
$recursive | boolean | integer | |
return | array |
public getChildrenByMatch ( $conditions, boolean | integer $recursive = true, boolean $check_self = false, $custom_filters = [] ) : array | ||
$conditions | See {$link match()} | |
$recursive | boolean | integer | Check recursively |
$check_self | boolean | Include this node in search? |
$custom_filters | See {$link match()} | |
return | array |
public getEncoding ( ) : string | boolean | ||
return | string | boolean | False if encoding could not be found |
public getInnerText ( ) : string | ||
return | string |
public getNextSibling ( boolean $skip_text_comments = true ) : |
||
$skip_text_comments | boolean | |
return | Null if not found |
public getOuterText ( ) : string | ||
return | string |
public getPlainText ( ) : string | ||
return | string |
public getPlainTextUTF8 ( ) : string | ||
return | string |
public getPreviousSibling ( boolean $skip_text_comments = true ) : |
||
$skip_text_comments | boolean | |
return | Null if not found |
public getRoot ( ) : |
||
return | Root, null if node has no parent |
public getSibling ( integer $offset = 1 ) : |
||
$offset | integer | Offset from current node |
return | Null if not found |
public insertChild ( string | |
||
$tag | string | |
Tagname or object |
return | Added node |
public isTextOrComment ( ) : boolean | ||
return | boolean |
protected match_attributes ( array $attributes ) : boolean | ||
$attributes | array | array('attr' => 'val') or array(array( 'operator_value' => 'equals'/'='/'contains_regex'/etc 'attribute' => 'attr', 'value' => 'val', 'match' => true, 'operator_result' => 'or'/'and', 'compare' => 'total'/'namespace'/'name', 'case_sensitive' => true)) |
return | boolean |
protected match_filters ( $conditions, array $custom_filters = [] ) : boolean | ||
$custom_filters | array | Custom map next to {@link $filter_map} |
return | boolean |
protected match_tags ( array $tags ) : boolean | ||
$tags | array | array('tag1', 'tag2') or array(array( 'tag' => 'tag1', 'operator' => 'or'/'and', 'compare' => 'total'/'namespace'/'name', 'case_sensitive' => true)) |
return | boolean |
public removeClass ( string | array $className ) | ||
$className | string | array |
public select ( string $query = '*', integer | boolean $index = false, boolean | integer $recursive = true, boolean $check_self = false ) : |
||
$query | string | |
$index | integer | boolean | True to return node instead of array if only 1 match, false to return array, int to return match at index, negative int to count from end |
$recursive | boolean | integer | |
$check_self | boolean | Include this node in search or only search child nodes |
return | Returns an array of matching {@link DomNode} objects or a single {@link DomNode} if `$index` is not false. |
public setAttributeNS ( string | integer $attr, string $namespace, string $compare = 'name', boolean $case_sensitive = false ) : boolean | ||
$attr | string | integer | Negative int to count from end |
$namespace | string | |
$compare | string | Find node using "namespace", "name" or "total" |
$case_sensitive | boolean | Compare with case sensitivity |
return | boolean |
public setPlainText ( string $text ) | ||
$text | string |
public toString ( boolean $attributes = true, boolean | integer $recursive = true, boolean | integer $content_only = false ) : string | ||
$attributes | boolean | Print attributes (of child tags) |
$recursive | boolean | integer | How many sub-levels of child tags to print. True for all. |
$content_only | boolean | integer | Only print text, false will print tags too. |
return | string |
protected toString_attributes ( ) : string | ||
return | string |
protected toString_content ( boolean $attributes = true, boolean | integer $recursive = true, boolean $content_only = false ) : string | ||
$attributes | boolean | Print attributes of child tags |
$recursive | boolean | integer | How many sublevels of childtags to print. True for all. |
$content_only | boolean | Only print text, false will print tags too. |
return | string |
public wrap ( string | |
||
$node | string | |
Wrapping node, string to create new element node |
$wrap_index | integer | Index to insert current node in wrapping node, -1 to append |
$node_index | integer | Index to insert wrapping node, null to keep at same position |
return | Wrapping node |
public wrapInner ( string | |
||
$node | string | |
Wrapping node, string to create new element node |
$start | integer | Index from child node where to start wrapping, 0 for first element |
$end | integer | Index from child node where to end wrapping, -1 for last element |
$wrap_index | integer | Index to insert in wrapping node, -1 to append |
$node_index | integer | Index to insert current node, null to keep at same position |
return | Wrapping node |
public bool $attribute_shorttag | ||
return | boolean |
public array $attributes_ns | ||
return | array |
public string $childClass | ||
return | string |
public string $childClass_ASP | ||
return | string |
public string $childClass_CDATA | ||
return | string |
public string $childClass_Comment | ||
return | string |
public string $childClass_Conditional | ||
return | string |
public string $childClass_Doctype | ||
return | string |
public string $childClass_Text | ||
return | string |
public string $childClass_XML | ||
return | string |
public array $filter_map | ||
return | array |
public bool $self_close | ||
return | boolean |
public string $self_close_str | ||
return | string |