PHP Класс pQuery\DomNode

Наследование: implements pquery\IQuery
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$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 DomNode 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

Открытые методы

Метод Описание
__construct ( string | array $tag, DomNode $parent ) 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 | DomNode $child, boolean $soft_delete = false ) Delete a child node
detach ( boolean $move_children_up = false ) Detach node from parent
dumpLocation ( ) : string Returns place in document
findChild ( DomNode $child ) : integer Find node in children
firstChild ( boolean $ignore_text_comments = false ) : DomNode 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 | DomNode $child, boolean $ignore_text_comments = false ) : DomNode 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 ) : DomNode 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 ) : DomNode Get node previous to current
getRoot ( ) : DomNode Get top parent
getSibling ( integer $offset = 1 ) : DomNode 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 ( DomNode $child ) : boolean Checks if node has another node as child
hasClass ( string $className ) : boolean Determine if node has a certain class
hasParent ( DomNode | string $tag = null, boolean $recursive = false ) : boolean 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 | DomNode $tag, $index ) : DomNode Insert childnode
isComment ( ) : boolean Find out if node is comment
isParent ( DomNode | string $tag, boolean $recursive = false ) : boolean 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 ) : DomNode 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 ) : DomNode[] | DomNode 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, HtmlParserBase $parser = null ) : boolean | array Similar to JavaScript innerText, will replace child nodes with new text
setNamespace ( string $ns ) Set namespace of node
setOuterText ( string $text, HtmlParserBase $parser = null ) : boolean | array 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 | DomNode
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 | DomNode $node, integer $wrap_index, integer $node_index = null ) : DomNode Wrap node
wrapInner ( string | DomNode $node, integer $start, integer $end, integer $wrap_index, integer $node_index = null ) : DomNode Wrap child nodes

Защищенные методы

Метод Описание
createNode ( string | DomNode $content ) : DomNode Create a {@link DomNode} from its string representation.
createNodes ( string | DomNode $content ) : DomNode[] 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)

Описание методов

__construct() публичный Метод

Class constructor
public __construct ( string | array $tag, DomNode $parent )
$tag string | array Name of the tag, or array with taginfo (array( 'tag_name' => 'tag', 'self_close' => false, 'attributes' => array('attribute' => 'value')))
$parent DomNode Parent of node, null if none

__destruct() публичный Метод

Class destructor
public __destruct ( )

__get() публичный Метод

Class magic get method, outputs {@link getAttribute()}
public __get ( $attribute ) : string
Результат string

__invoke() публичный Метод

Class magic invoke method, performs {@link query()}.
public __invoke ( string $query = '*' ) : pQuery
$query string The css query to run on the nodes.
Результат pQuery

__isset() публичный Метод

Class magic isset method, returns {@link hasAttribute()}
public __isset ( $attribute ) : boolean
Результат boolean

__set() публичный Метод

Class magic set method, performs {@link setAttribute()}
public __set ( $attribute, $value )

__toString() публичный Метод

Class toString, outputs {@link $tag}
public __toString ( ) : string
Результат string

__unset() публичный Метод

Class magic unset method, performs {@link deleteAttribute()}
public __unset ( $attribute )

addASP() публичный Метод

#php5
public addASP ( $tag = '', $text = '', $attributes = [], &$offset = null )

addAttribute() публичный Метод

Add new attribute
public addAttribute ( string $attr, string $val )
$attr string
$val string

addCDATA() публичный Метод

#php5
public addCDATA ( $text, &$offset = null )

addChild() публичный Метод

#php5
public addChild ( $tag, &$offset = null )

addClass() публичный Метод

Add new class(es)
public addClass ( string | array $className )
$className string | array

addComment() публичный Метод

#php5
public addComment ( $text, &$offset = null )

addConditional() публичный Метод

#php5
public addConditional ( $condition, $hidden = true, &$offset = null )

addDoctype() публичный Метод

#php5
public addDoctype ( $dtd, &$offset = null )

addText() публичный Метод

#php5
public addText ( $text, &$offset = null )

addXML() публичный Метод

#php5
public addXML ( $tag = 'xml', $text = '', $attributes = [], &$offset = null )

after() публичный Метод

public after ( $content )

append() публичный Метод

public append ( $content )

attr() публичный Метод

public attr ( $name, $value = null )

attributeCount() публичный Метод

Number of attributes
public attributeCount ( ) : integer
Результат integer

before() публичный Метод

public before ( $content )

changeParent() публичный Метод

#php5
public changeParent ( $to, &$index = null )

childCount() публичный Метод

Number of children in node
public childCount ( boolean $ignore_text_comments = false ) : integer
$ignore_text_comments boolean Ignore text/comments with calculation
Результат integer

clear() публичный Метод

Deletes all child nodes from node
public clear ( )

count() публичный Метод

public count ( )

createNode() защищенный Метод

Create a {@link DomNode} from its string representation.
protected createNode ( string | DomNode $content ) : DomNode
$content string | DomNode
Результат DomNode

createNodes() защищенный Метод

Create an array of {@link DomNode} objects from their string representation.
protected createNodes ( string | DomNode $content ) : DomNode[]
$content string | DomNode
Результат DomNode[]

delete() публичный Метод

Delete node from parent and clear node
public delete ( )

deleteAttribute() публичный Метод

Delete attribute(s)
public deleteAttribute ( string | integer $attr, string $compare = 'total', boolean $case_sensitive = false )
$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

deleteChild() публичный Метод

Delete a child node
public deleteChild ( integer | DomNode $child, boolean $soft_delete = false )
$child integer | DomNode Child(index) to delete, negative to count from end
$soft_delete boolean False to call {@link delete()} from child

detach() публичный Метод

Detach node from parent
См. также: delete()
public detach ( boolean $move_children_up = false )
$move_children_up boolean Only detach current node and replace it with child nodes

dumpLocation() публичный Метод

Returns place in document
public dumpLocation ( ) : string
Результат string

filter_checked() защищенный Метод

Checks if a node matches css query filter ":checked"
См. также: match()
protected filter_checked ( ) : boolean
Результат boolean

filter_comment() защищенный Метод

Checks if node matches css query filter ":comment"
См. также: match()
protected filter_comment ( ) : boolean
Результат boolean

filter_contains() защищенный Метод

Checks if node matches css query filter ":contains(s)"
См. также: match()
protected filter_contains ( string $text ) : boolean
$text string
Результат boolean

filter_element() защищенный Метод

Checks if node matches css query filter ":element"
См. также: match()
protected filter_element ( ) : boolean
Результат boolean

filter_empty() защищенный Метод

Checks if node matches css query filter ":empty"
См. также: match()
protected filter_empty ( ) : boolean
Результат boolean

filter_even() защищенный Метод

Checks if node matches css query filter ":even"
См. также: match()
protected filter_even ( ) : boolean
Результат boolean

filter_every() защищенный Метод

Checks if node matches css query filter ":every(n)"
См. также: match()
protected filter_every ( $n ) : boolean
Результат boolean

filter_first() защищенный Метод

Checks if node matches css query filter ":first"
См. также: match()
protected filter_first ( ) : boolean
Результат boolean

filter_firsttype() защищенный Метод

Checks if node matches css query filter ":first-of-type"
См. также: match()
protected filter_firsttype ( ) : boolean
Результат boolean

filter_gt() защищенный Метод

Checks if node matches css query filter ":gt(n)"
См. также: match()
protected filter_gt ( string $n ) : boolean
$n string 0-based index
Результат boolean

filter_has() защищенный Метод

Checks if node matches css query filter ":has(s)"
См. также: match()
protected filter_has ( string $selector ) : boolean
$selector string
Результат boolean

filter_hastext() защищенный Метод

Checks if node matches css query filter ":has-text"
См. также: match()
protected filter_hastext ( ) : boolean
Результат boolean

filter_lang() защищенный Метод

Checks if node matches css query filter ":lang(s)"
См. также: match()
protected filter_lang ( string $lang ) : boolean
$lang string
Результат boolean

filter_last() защищенный Метод

Checks if node matches css query filter ":last"
См. также: match()
protected filter_last ( ) : boolean
Результат boolean

filter_lasttype() защищенный Метод

Checks if node matches css query filter ":last-of-type"
См. также: match()
protected filter_lasttype ( ) : boolean
Результат boolean

filter_lt() защищенный Метод

Checks if node matches css query filter ":lt(n)"
См. также: match()
protected filter_lt ( string $n ) : boolean
$n string 0-based index
Результат boolean

filter_nchild() защищенный Метод

Checks if node matches css query filter ":nth-child(n)"
См. также: match()
protected filter_nchild ( string $n ) : boolean
$n string 1-based index
Результат boolean

filter_nlastchild() защищенный Метод

Checks if node matches css query filter ":nth-last-child(n)"
См. также: match()
protected filter_nlastchild ( string $n ) : boolean
$n string 1-based index
Результат boolean

filter_nlastype() защищенный Метод

Checks if node matches css query filter ":nth-last-of-type(n)"
См. также: match()
protected filter_nlastype ( string $n ) : boolean
$n string 1-based index
Результат boolean

filter_not() защищенный Метод

Checks if node matches css query filter ":not(s)"
См. также: match()
protected filter_not ( string $selector ) : boolean
$selector string
Результат boolean

filter_notempty() защищенный Метод

Checks if node matches css query filter ":not-empty"
См. также: match()
protected filter_notempty ( ) : boolean
Результат boolean

filter_notext() защищенный Метод

Checks if node matches css query filter ":no-text"
См. также: match()
protected filter_notext ( ) : boolean
Результат boolean

filter_ntype() защищенный Метод

Checks if node matches css query filter ":nth-of-type(n)"
См. также: match()
protected filter_ntype ( string $n ) : boolean
$n string 1-based index
Результат boolean

filter_odd() защищенный Метод

Checks if node matches css query filter ":odd"
См. также: match()
protected filter_odd ( ) : boolean
Результат boolean

filter_onlychild() защищенный Метод

Checks if node matches css query filter ":only-child"
См. также: match()
protected filter_onlychild ( ) : boolean
Результат boolean

filter_onlytype() защищенный Метод

Checks if node matches css query filter ":only-of-type"
См. также: match()
protected filter_onlytype ( ) : boolean
Результат boolean

filter_root() защищенный Метод

Checks if node matches css query filter ":root"
См. также: match()
protected filter_root ( ) : boolean
Результат boolean

filter_selected() защищенный Метод

Checks if a node matches css query filter ":selected"
См. также: match()
protected filter_selected ( ) : boolean
Результат boolean

filter_text() защищенный Метод

Checks if node matches css query filter ":text"
См. также: match()
protected filter_text ( ) : boolean
Результат boolean

findAttribute() защищенный Метод

Find attribute using namespace, name or both
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
Результат array array('ns', 'attr', 'ns:attr', index)

findChild() публичный Метод

Find node in children
public findChild ( DomNode $child ) : integer
$child DomNode
Результат integer False if not found

firstChild() публичный Метод

First child node
public firstChild ( boolean $ignore_text_comments = false ) : DomNode
$ignore_text_comments boolean Ignore text/comments with index calculation
Результат DomNode

getAttribute() публичный Метод

Gets value(s) of attribute(s)
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
Результат string | array

getAttributeNS() публичный Метод

Gets namespace of attribute(s)
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
Результат string | array False if not found

getChild() публичный Метод

Get childnode
public getChild ( integer | DomNode $child, boolean $ignore_text_comments = false ) : DomNode
$child integer | DomNode Index, negative to count from end
$ignore_text_comments boolean Ignore text/comments with index calculation
Результат DomNode

getChildrenByAttribute() публичный Метод

Finds children that match a certain attribute
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
Результат array

getChildrenByCallback() публичный Метод

Finds children using a callback function
public getChildrenByCallback ( callable $callback, boolean | integer $recursive = true, boolean $check_self = false ) : array
$callback callable Function($node) that returns a bool
$recursive boolean | integer Check recursively
$check_self boolean Include this node in search?
Результат array

getChildrenByClass() публичный Метод

Finds all children using class attribute
public getChildrenByClass ( string $class, boolean | integer $recursive = true ) : array
$class string
$recursive boolean | integer
Результат array

getChildrenByID() публичный Метод

Finds all children using ID attribute
public getChildrenByID ( string $id, boolean | integer $recursive = true ) : array
$id string
$recursive boolean | integer
Результат array

getChildrenByMatch() публичный Метод

Finds children using the {$link match()} function
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()}
Результат array

getChildrenByName() публичный Метод

Finds all children using name attribute
public getChildrenByName ( string $name, boolean | integer $recursive = true ) : array
$name string
$recursive boolean | integer
Результат array

getChildrenByTag() публичный Метод

Finds children that match a certain tag
public getChildrenByTag ( string $tag, string $compare = 'total', boolean | integer $recursive = true ) : array
$tag string
$compare string "total"/"namespace"/"name"
$recursive boolean | integer
Результат array

getEncoding() публичный Метод

Try to determine the encoding of the current tag
public getEncoding ( ) : string | boolean
Результат string | boolean False if encoding could not be found

getInnerText() публичный Метод

Similar to JavaScript innerText, will return (html formatted) content
public getInnerText ( ) : string
Результат string

getNamespace() публичный Метод

Get namespace of node
См. также: setNamespace()
public getNamespace ( ) : string
Результат string

getNextSibling() публичный Метод

Get node next to current
См. также: getSibling()
См. также: getPreviousSibling()
public getNextSibling ( boolean $skip_text_comments = true ) : DomNode
$skip_text_comments boolean
Результат DomNode Null if not found

getOuterText() публичный Метод

Similar to JavaScript outerText, will return full (html formatted) node
public getOuterText ( ) : string
Результат string

getPlainText() публичный Метод

Similar to JavaScript plainText, will return text in node (and subnodes)
public getPlainText ( ) : string
Результат string

getPlainTextUTF8() публичный Метод

Return plaintext taking document encoding into account
public getPlainTextUTF8 ( ) : string
Результат string

getPreviousSibling() публичный Метод

Get node previous to current
См. также: getSibling()
См. также: getNextSibling()
public getPreviousSibling ( boolean $skip_text_comments = true ) : DomNode
$skip_text_comments boolean
Результат DomNode Null if not found

getRoot() публичный Метод

Get top parent
public getRoot ( ) : DomNode
Результат DomNode Root, null if node has no parent

getSibling() публичный Метод

Get sibling node
public getSibling ( integer $offset = 1 ) : DomNode
$offset integer Offset from current node
Результат DomNode Null if not found

getTag() публичный Метод

Get tagname of node (without namespace)
См. также: setTag()
public getTag ( ) : string
Результат string

hasAttribute() публичный Метод

Checks if node has attribute
public hasAttribute ( $attr, string $compare = 'total', boolean $case_sensitive = false ) : boolean
$compare string Find node using "namespace", "name" or "total"
$case_sensitive boolean Compare with case sensitivity
Результат boolean

hasChild() публичный Метод

Checks if node has another node as child
public hasChild ( DomNode $child ) : boolean
$child DomNode
Результат boolean

hasClass() публичный Метод

Determine if node has a certain class
public hasClass ( string $className ) : boolean
$className string
Результат boolean

hasParent() публичный Метод

Find out if node has (a certain) parent
public hasParent ( DomNode | string $tag = null, boolean $recursive = false ) : boolean
$tag DomNode | string Match against parent, string to match tag, object to fully match node, null to return if node has parent
$recursive boolean
Результат boolean

html() публичный Метод

Return html code of node
См. также: toString()
public html ( string | null $value = null ) : string
$value string | null The value to set or null to get the value.
Результат string

indent() публичный Метод

Calculate indent of node (number of parent tags - 1)
public indent ( ) : integer
Результат integer

index() публичный Метод

Index of node in parent
public index ( boolean $count_all = true ) : integer
$count_all boolean True to count all tags, false to ignore text and comments
Результат integer -1 if not found

insertChild() публичный Метод

Insert childnode
public insertChild ( string | DomNode $tag, $index ) : DomNode
$tag string | DomNode Tagname or object
Результат DomNode Added node

isComment() публичный Метод

Find out if node is comment
public isComment ( ) : boolean
Результат boolean

isParent() публичный Метод

Find out if node is parent of a certain tag
См. также: hasParent()
public isParent ( DomNode | string $tag, boolean $recursive = false ) : boolean
$tag DomNode | string Match against parent, string to match tag, object to fully match node
$recursive boolean
Результат boolean

isText() публичный Метод

Find out if node is text
public isText ( ) : boolean
Результат boolean

isTextOrComment() публичный Метод

Find out if node is text or comment node
public isTextOrComment ( ) : boolean
Результат boolean

lastChild() публичный Метод

Last child node
public lastChild ( boolean $ignore_text_comments = false ) : DomNode
$ignore_text_comments boolean Ignore text/comments with index calculation
Результат DomNode

match() публичный Метод

Checks if node matches certain conditions
public match ( $conditions, array $match = true, array $custom_filters = [] ) : boolean
$match array Should conditions evaluate to true?
$custom_filters array Custom map next to {@link $filter_map}
Результат boolean

match_attributes() защищенный Метод

Checks if attributes match certain conditions
См. также: match()
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))
Результат boolean

match_filters() защищенный Метод

Checks if node matches certain filters
См. также: match()
protected match_filters ( $conditions, array $custom_filters = [] ) : boolean
$custom_filters array Custom map next to {@link $filter_map}
Результат boolean

match_tags() защищенный Метод

Checks if tag matches certain conditions
См. также: match()
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))
Результат boolean

move() публичный Метод

#php5
public move ( $to, &$new_index )

moveChildren() публичный Метод

#php5
public moveChildren ( $to, &$new_index, $start, $end )

prepend() публичный Метод

}
public prepend ( $content = null )

prop() публичный Метод

public prop ( $name, $value = null )

query() публичный Метод

Performs a css query on the node.
public query ( string $query = '*' ) : pquery\IQuery
$query string
Результат pquery\IQuery Returns the matching nodes from the query.

remove() публичный Метод

public remove ( $selector = null )

removeAttr() публичный Метод

public removeAttr ( $name )

removeClass() публичный Метод

Remove clas(ses)
public removeClass ( string | array $className )
$className string | array

replaceWith() публичный Метод

public replaceWith ( $content )

select() публичный Метод

Performs css query on node
public select ( string $query = '*', integer | boolean $index = false, boolean | integer $recursive = true, boolean $check_self = false ) : DomNode[] | DomNode
$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
Результат DomNode[] | DomNode Returns an array of matching {@link DomNode} objects or a single {@link DomNode} if `$index` is not false.

setAttribute() публичный Метод

Sets value(s) of attribute(s)
public setAttribute ( string | integer $attr, $val, string $compare = 'total', boolean $case_sensitive = false )
$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

setAttributeNS() публичный Метод

Sets namespace of attribute(s)
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
Результат boolean

setIndex() публичный Метод

Change index of node in parent
public setIndex ( integer $index )
$index integer New index

setInnerText() публичный Метод

Similar to JavaScript innerText, will replace child nodes with new text
public setInnerText ( string $text, HtmlParserBase $parser = null ) : boolean | array
$text string
$parser HtmlParserBase Null to auto create instance
Результат boolean | array True on succeed, array with errors on failure

setNamespace() публичный Метод

Set namespace of node
См. также: getNamespace()
public setNamespace ( string $ns )
$ns string

setOuterText() публичный Метод

Similar to JavaScript outerText, will replace node (and child nodes) with new text
public setOuterText ( string $text, HtmlParserBase $parser = null ) : boolean | array
$text string
$parser HtmlParserBase Null to auto create instance
Результат boolean | array True on succeed, array with errors on failure

setPlainText() публичный Метод

Similar to JavaScript plainText, will replace child nodes with new text (literal)
public setPlainText ( string $text )
$text string

setTag() публичный Метод

Set tag (with or without namespace)
См. также: getTag()
public setTag ( string $tag, boolean $with_ns = false )
$tag string
$with_ns boolean Does $tag include namespace?

tagName() публичный Метод

public tagName ( type $value = null ) : string | DomNode
$value type
Результат string | DomNode

text() публичный Метод

public text ( $value = null )

toString() публичный Метод

Returns the node as 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.
Результат string

toString_attributes() защищенный Метод

Returns all the attributes and their values
protected toString_attributes ( ) : string
Результат string

toString_content() защищенный Метод

Returns the content of the node (child tags and text)
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.
Результат string

toggleClass() публичный Метод

public toggleClass ( $classname, $switch = null )

typeIndex() публичный Метод

Index of all similar nodes in parent
public typeIndex ( ) : integer
Результат integer -1 if not found

unwrap() публичный Метод

public unwrap ( )

val() публичный Метод

public val ( $value = null )

wrap() публичный Метод

Wrap node
public wrap ( string | DomNode $node, integer $wrap_index, integer $node_index = null ) : DomNode
$node string | DomNode 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
Результат DomNode Wrapping node

wrapInner() публичный Метод

Wrap child nodes
public wrapInner ( string | DomNode $node, integer $start, integer $end, integer $wrap_index, integer $node_index = null ) : DomNode
$node string | DomNode 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
Результат DomNode Wrapping node

Описание свойств

$attribute_shorttag публичное свойство

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.
public bool $attribute_shorttag
Результат boolean

$attributes публичное свойство

Attributes of node
См. также: getAttribute()
См. также: setAttribute()
public array $attributes
Результат array

$attributes_ns публичное свойство

Namespace info for attributes
См. также: findAttribute()
public array $attributes_ns
Результат array

$childClass публичное свойство

Name of the class used for {@link addChild()}
public string $childClass
Результат string

$childClass_ASP публичное свойство

Name of the class used for {@link addASP()}
public string $childClass_ASP
Результат string

$childClass_CDATA публичное свойство

Name of the class used for {@link addCDATA()}
public string $childClass_CDATA
Результат string

$childClass_Comment публичное свойство

Name of the class used for {@link addComment()}
public string $childClass_Comment
Результат string

$childClass_Conditional публичное свойство

Name of the class used for {@link addContional()}
public string $childClass_Conditional
Результат string

$childClass_Doctype публичное свойство

Name of the class used for {@link addDoctype()}
public string $childClass_Doctype
Результат string

$childClass_Text публичное свойство

Name of the class used for {@link addText()}
public string $childClass_Text
Результат string

$childClass_XML публичное свойство

Name of the class used for {@link addXML()}
public string $childClass_XML
Результат string

$children публичное свойство

Array of child nodes
См. также: childCount()
См. также: getChild()
См. также: addChild()
См. также: deleteChild()
public array $children
Результат array

$filter_map публичное свойство

Function map used for the selector filter
public array $filter_map
Результат array

$parent публичное свойство

Parent node, null if none
См. также: changeParent()
public DomNode,pquery $parent
Результат DomNode

$parserClass публичное свойство

Name of the parser class
См. также: setOuterText()
См. также: setInnerText()
public string $parserClass
Результат string

$selectClass публичное свойство

Name of the selector class
См. также: select()
public string $selectClass
Результат string

$self_close публичное свойство

Is node a self closing node? No closing tag if true.
public bool $self_close
Результат boolean

$self_close_str публичное свойство

If self close, then this will be used to close the tag
public string $self_close_str
Результат string

$tag публичное свойство

Full tag name (including namespace)
См. также: getTagName()
См. также: getNamespace()
public string $tag
Результат string

$tag_ns публичное свойство

Namespace info for tag
public array $tag_ns
Результат array