PHP 클래스 PHPHtmlParser\Dom

파일 보기 프로젝트 열기: paquettg/php-html-parser 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$root PHPHtmlParser\Dom\HtmlNode Contains the root node of this dom tree.

보호된 프로퍼티들

프로퍼티 타입 설명
$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