PHP Class PHPHtmlParser\Dom\AbstractNode

Exibir arquivo Open project: paquettg/php-html-parser Class Usage Examples

Protected Properties

Property Type Description
$attr array Contains a list of attributes on this tag.
$encode mixed The encoding class used to encode strings.
$id string The unique id of the class. Given by PHP.
$parent InnerNode Contains the parent Node.
$tag Tag Contains the tag name/type

Public Methods

Method Description
__construct ( ) Creates a unique spl hash for this node.
__destruct ( ) Attempts to clear out any object references.
__get ( string $key ) : mixed Magic get method for attributes and certain methods.
__toString ( ) : string Simply calls the outer text method.
ancestorByTag ( string $tag ) : AbstractNode Function to locate a specific ancestor tag in the path to the root.
delete ( ) : void Removes this node and all its children from the DOM tree.
find ( string $selector, integer $nth = null ) : array | AbstractNode Find elements by css selector
getAncestor ( integer $id ) : null | AbstractNode Attempts to get an ancestor node by the given id.
getAttribute ( string $key ) : mixed A wrapper method that simply calls the getAttribute method on the tag of this node.
getAttributes ( ) : array A wrapper method that simply calls the getAttribute method on the tag of this node.
getParent ( ) : AbstractNode Returns the parent of node.
getTag ( ) : Tag Gets the tag object of this node.
id ( ) Returns the id of this object.
innerHtml ( ) : string Gets the inner html of this node.
isAncestor ( integer $id ) : boolean Checks if the given node id is an ancestor of the current node.
nextSibling ( ) : AbstractNode Attempts to get the next sibling.
outerHtml ( ) : string Gets the html of this node, including it's own tag.
previousSibling ( ) : AbstractNode Attempts to get the previous sibling
propagateEncoding ( stringEncode\Encode $encode ) : void Sets the encoding class to this node.
removeAllAttributes ( ) : void A wrapper method that simply calls the removeAllAttributes method on the tag of this node.
removeAttribute ( string $key ) : void A wrapper method that simply calls the removeAttribute method on the tag of this node.
setAttribute ( string $key, string $value ) A wrapper method that simply calls the setAttribute method on the tag of this node.
setParent ( InnerNode $parent ) Sets the parent node.
text ( ) : string Gets the text of this node (if there is any text).

Protected Methods

Method Description
clear ( ) : void Call this when something in the node tree has changed. Like a child has been added or a parent has been changed.

Method Details

__construct() public method

Creates a unique spl hash for this node.
public __construct ( )

__destruct() public method

Attempts to clear out any object references.
public __destruct ( )

__get() public method

Magic get method for attributes and certain methods.
public __get ( string $key ) : mixed
$key string
return mixed

__toString() public method

Simply calls the outer text method.
public __toString ( ) : string
return string

ancestorByTag() public method

Function to locate a specific ancestor tag in the path to the root.
public ancestorByTag ( string $tag ) : AbstractNode
$tag string
return AbstractNode

clear() abstract protected method

Call this when something in the node tree has changed. Like a child has been added or a parent has been changed.
abstract protected clear ( ) : void
return void

delete() public method

Removes this node and all its children from the DOM tree.
public delete ( ) : void
return void

find() public method

Find elements by css selector
public find ( string $selector, integer $nth = null ) : array | AbstractNode
$selector string
$nth integer
return array | AbstractNode

getAncestor() public method

Attempts to get an ancestor node by the given id.
public getAncestor ( integer $id ) : null | AbstractNode
$id integer
return null | AbstractNode

getAttribute() public method

A wrapper method that simply calls the getAttribute method on the tag of this node.
public getAttribute ( string $key ) : mixed
$key string
return mixed

getAttributes() public method

A wrapper method that simply calls the getAttribute method on the tag of this node.
public getAttributes ( ) : array
return array

getParent() public method

Returns the parent of node.
public getParent ( ) : AbstractNode
return AbstractNode

getTag() public method

Gets the tag object of this node.
public getTag ( ) : Tag
return Tag

id() public method

Returns the id of this object.
public id ( )

innerHtml() abstract public method

Gets the inner html of this node.
abstract public innerHtml ( ) : string
return string

isAncestor() public method

Checks if the given node id is an ancestor of the current node.
public isAncestor ( integer $id ) : boolean
$id integer
return boolean

nextSibling() public method

Attempts to get the next sibling.
public nextSibling ( ) : AbstractNode
return AbstractNode

outerHtml() abstract public method

Gets the html of this node, including it's own tag.
abstract public outerHtml ( ) : string
return string

previousSibling() public method

Attempts to get the previous sibling
public previousSibling ( ) : AbstractNode
return AbstractNode

propagateEncoding() public method

Sets the encoding class to this node.
public propagateEncoding ( stringEncode\Encode $encode ) : void
$encode stringEncode\Encode
return void

removeAllAttributes() public method

A wrapper method that simply calls the removeAllAttributes method on the tag of this node.
public removeAllAttributes ( ) : void
return void

removeAttribute() public method

A wrapper method that simply calls the removeAttribute method on the tag of this node.
public removeAttribute ( string $key ) : void
$key string
return void

setAttribute() public method

A wrapper method that simply calls the setAttribute method on the tag of this node.
public setAttribute ( string $key, string $value )
$key string
$value string

setParent() public method

Sets the parent node.
public setParent ( InnerNode $parent )
$parent InnerNode

text() abstract public method

Gets the text of this node (if there is any text).
abstract public text ( ) : string
return string

Property Details

$attr protected_oe property

Contains a list of attributes on this tag.
protected array $attr
return array

$encode protected_oe property

The encoding class used to encode strings.
protected mixed $encode
return mixed

$id protected_oe property

The unique id of the class. Given by PHP.
protected string $id
return string

$parent protected_oe property

Contains the parent Node.
protected InnerNode,PHPHtmlParser\Dom $parent
return InnerNode

$tag protected_oe property

Contains the tag name/type
protected Tag,PHPHtmlParser\Dom $tag
return Tag