PHP Класс PHPHtmlParser\Dom

Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$root PHPHtmlParser\Dom\HtmlNode Contains the root node of this dom tree.

Защищенные свойства (Protected)

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

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

Метод Описание
__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.

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

Метод Описание
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.

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

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

A simple wrapper around the root node.
public __get ( string $name ) : mixed
$name string
Результат mixed

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

Returns the inner html of the root node.
public __toString ( ) : string
Результат string

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

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() защищенный Метод

Cleans the html of any none-html information.
protected clean ( string $str ) : string
$str string
Результат string

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

Sets the list of self closing tags to empty.

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

Attempts to detect the charset that the html was sent in.
protected detectCharset ( ) : boolean
Результат boolean

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

Find elements by css selector on the root node.
public find ( string $selector, integer $nth = null ) : array
$selector string
$nth integer
Результат array

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

Simple wrapper function that returns the first child.
public firstChild ( ) : AbstractNode
Результат PHPHtmlParser\Dom\AbstractNode

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

Simple wrapper function that returns an element by the id.
public getElementById ( string $id ) : AbstractNode
$id string
Результат PHPHtmlParser\Dom\AbstractNode

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

Simple wrapper function that returns all elements by class name.
public getElementsByClass ( string $class ) : array
$class string
Результат array

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

Simple wrapper function that returns all elements by tag name.
public getElementsByTag ( string $name ) : array
$name string
Результат array

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

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

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

Simple wrapper function that returns the last child.
public lastChild ( ) : AbstractNode
Результат PHPHtmlParser\Dom\AbstractNode

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

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

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

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

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

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() публичный Метод

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

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

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

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

Attempt to parse a tag out of the content.
protected parseTag ( ) : array
Результат array

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

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() публичный Метод

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

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

$content защищенное свойство

The document string.
protected Content,phphtmlparser $content
Результат Content

$defaultCharset защищенное свойство

The charset we would like the output to be in.
protected string $defaultCharset
Результат string

$globalOptions защищенное свойство

A global options array to be used by all load calls.
protected array $globalOptions
Результат array

$options защищенное свойство

A persistent option object to be used for all options in the parsing of the file.
protected Options,phphtmlparser $options
Результат Options

$raw защищенное свойство

The raw version of the document string.
protected string $raw
Результат string

$rawSize защищенное свойство

The original file size of the document.
protected int $rawSize
Результат integer

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

Contains the root node of this dom tree.
public HtmlNode,PHPHtmlParser\Dom $root
Результат PHPHtmlParser\Dom\HtmlNode

$selfClosing защищенное свойство

A list of tags which will always be self closing
protected array $selfClosing
Результат array

$size защищенное свойство

The size of the document after it is cleaned.
protected int $size
Результат integer