PHP Class PHPHtmlParser\Dom

Afficher le fichier Open project: paquettg/php-html-parser Class Usage Examples

Méthodes publiques

Свойство Type Description
$root PHPHtmlParser\Dom\HtmlNode Contains the root node of this dom tree.

Protected Properties

Свойство Type Description
$content Content The document string.
$defaultCharset string The charset we would like the output to be in.
$globalOptions array A global options array to be used by all load calls.
$options Options A persistent option object to be used for all options in the parsing of the file.
$raw string The raw version of the document string.
$rawSize integer The original file size of the document.
$selfClosing array A list of tags which will always be self closing
$size integer The size of the document after it is cleaned.

Méthodes publiques

Méthode Description
__get ( string $name ) : mixed A simple wrapper around the root node.
__toString ( ) : string Returns the inner html of the root node.
addSelfClosingTag ( string | array $tag ) Adds the tag (or tags in an array) to the list of tags that will always be self closing.
clearSelfClosingTags ( ) Sets the list of self closing tags to empty.
find ( string $selector, integer $nth = null ) : array Find elements by css selector on the root node.
firstChild ( ) : AbstractNode Simple wrapper function that returns the first child.
getElementById ( string $id ) : AbstractNode Simple wrapper function that returns an element by the id.
getElementsByClass ( string $class ) : array Simple wrapper function that returns all elements by class name.
getElementsByTag ( string $name ) : array Simple wrapper function that returns all elements by tag name.
lastChild ( ) : AbstractNode Simple wrapper function that returns the last child.
load ( string $str, array $options = [] ) Attempts to load the dom from any resource, string, file, or URL.
loadFromFile ( string $file, array $options = [] ) Loads the dom from a document file/url
loadFromUrl ( string $url, array $options = [], phphtmlparser\CurlInterface $curl = null ) Use a curl interface implementation to attempt to load the content from a url.
loadStr ( string $str, array $option ) Parsers the html of the given string. Used for load(), loadFromFile(), and loadFromUrl().
removeSelfClosingTag ( string | array $tag ) Removes the tag (or tags in an array) from the list of tags that will always be self closing.
setOptions ( array $options ) Sets a global options array to be used by all load calls.

Méthodes protégées

Méthode Description
clean ( string $str ) : string Cleans the html of any none-html information.
detectCharset ( ) : boolean Attempts to detect the charset that the html was sent in.
isLoaded ( ) Checks if the load methods have been called.
parse ( ) Attempts to parse the html in content.
parseTag ( ) : array Attempt to parse a tag out of the content.

Method Details

__get() public méthode

A simple wrapper around the root node.
public __get ( string $name ) : mixed
$name string
Résultat mixed

__toString() public méthode

Returns the inner html of the root node.
public __toString ( ) : string
Résultat string

addSelfClosingTag() public méthode

Adds the tag (or tags in an array) to the list of tags that will always be self closing.
public addSelfClosingTag ( string | array $tag )
$tag string | array

clean() protected méthode

Cleans the html of any none-html information.
protected clean ( string $str ) : string
$str string
Résultat string

clearSelfClosingTags() public méthode

Sets the list of self closing tags to empty.

detectCharset() protected méthode

Attempts to detect the charset that the html was sent in.
protected detectCharset ( ) : boolean
Résultat boolean

find() public méthode

Find elements by css selector on the root node.
public find ( string $selector, integer $nth = null ) : array
$selector string
$nth integer
Résultat array

firstChild() public méthode

Simple wrapper function that returns the first child.
public firstChild ( ) : AbstractNode
Résultat PHPHtmlParser\Dom\AbstractNode

getElementById() public méthode

Simple wrapper function that returns an element by the id.
public getElementById ( string $id ) : AbstractNode
$id string
Résultat PHPHtmlParser\Dom\AbstractNode

getElementsByClass() public méthode

Simple wrapper function that returns all elements by class name.
public getElementsByClass ( string $class ) : array
$class string
Résultat array

getElementsByTag() public méthode

Simple wrapper function that returns all elements by tag name.
public getElementsByTag ( string $name ) : array
$name string
Résultat array

isLoaded() protected méthode

Checks if the load methods have been called.
protected isLoaded ( )

lastChild() public méthode

Simple wrapper function that returns the last child.
public lastChild ( ) : AbstractNode
Résultat PHPHtmlParser\Dom\AbstractNode

load() public méthode

Attempts to load the dom from any resource, string, file, or URL.
public load ( string $str, array $options = [] )
$str string
$options array

loadFromFile() public méthode

Loads the dom from a document file/url
public loadFromFile ( string $file, array $options = [] )
$file string
$options array

loadFromUrl() public méthode

Use a curl interface implementation to attempt to load the content from a url.
public loadFromUrl ( string $url, array $options = [], phphtmlparser\CurlInterface $curl = null )
$url string
$options array
$curl phphtmlparser\CurlInterface

loadStr() public méthode

Parsers the html of the given string. Used for load(), loadFromFile(), and loadFromUrl().
public loadStr ( string $str, array $option )
$str string
$option array

parse() protected méthode

Attempts to parse the html in content.
protected parse ( )

parseTag() protected méthode

Attempt to parse a tag out of the content.
protected parseTag ( ) : array
Résultat array

removeSelfClosingTag() public méthode

Removes the tag (or tags in an array) from the list of tags that will always be self closing.
public removeSelfClosingTag ( string | array $tag )
$tag string | array

setOptions() public méthode

Sets a global options array to be used by all load calls.
public setOptions ( array $options )
$options array

Property Details

$content protected_oe property

The document string.
protected Content,phphtmlparser $content
Résultat Content

$defaultCharset protected_oe property

The charset we would like the output to be in.
protected string $defaultCharset
Résultat string

$globalOptions protected_oe property

A global options array to be used by all load calls.
protected array $globalOptions
Résultat array

$options protected_oe property

A persistent option object to be used for all options in the parsing of the file.
protected Options,phphtmlparser $options
Résultat Options

$raw protected_oe property

The raw version of the document string.
protected string $raw
Résultat string

$rawSize protected_oe property

The original file size of the document.
protected int $rawSize
Résultat integer

$root public_oe property

Contains the root node of this dom tree.
public HtmlNode,PHPHtmlParser\Dom $root
Résultat PHPHtmlParser\Dom\HtmlNode

$selfClosing protected_oe property

A list of tags which will always be self closing
protected array $selfClosing
Résultat array

$size protected_oe property

The size of the document after it is cleaned.
protected int $size
Résultat integer