Copied!

Class Dom

  • package PHPHtmlParser
Cloneable Instantiable
Properties
public $root
 

Contains the root node of this dom tree.

  • var HtmlNode
Methods
public __get ( $name )
 

A simple wrapper around the root node.

  • return mixed
public __toString () : string
 

Returns the inner html of the root node.

  • return string
  • throws ChildNotFoundException
  • throws UnknownChildTypeException
public addNoSlashTag ( $tag ) : PHPHtmlParser\Dom
 

Adds a tag to the list of self closing tags that should not have a trailing slash

public addSelfClosingTag ( $tag ) : PHPHtmlParser\Dom
 

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

public clearNoSlashTags () : PHPHtmlParser\Dom
 

Empties the list of no-slash tags.

public clearSelfClosingTags () : PHPHtmlParser\Dom
 

Sets the list of self closing tags to empty.

public countChildren () : int
 

Simple wrapper function that returns count of child elements

  • return int
  • throws NotLoadedException
public find ( string $selector , ? int $nth = NULL )
 

Find elements by css selector on the root node.

  • return mixed | Collection | null
  • throws ChildNotFoundException
  • throws NotLoadedException
public findById ( int $id )
 

Find element by Id on the root node

  • return bool | AbstractNode
  • throws ChildNotFoundException
  • throws NotLoadedException
  • throws ParentNotFoundException
public firstChild () : PHPHtmlParser\Dom\AbstractNode
 

Simple wrapper function that returns the first child.

  • return AbstractNode
  • throws ChildNotFoundException
  • throws NotLoadedException
public getChildren () : array
 

Get array of children

  • return array
  • throws NotLoadedException
public getElementById ( $id )
 

Simple wrapper function that returns an element by the
id.

  • return mixed | Collection | null
  • throws ChildNotFoundException
  • throws NotLoadedException
public getElementsByClass ( string $class )
 

Simple wrapper function that returns all elements by
class name.

  • return mixed | Collection | null
  • throws ChildNotFoundException
  • throws NotLoadedException
public getElementsByTag ( string $name )
 

Simple wrapper function that returns all elements by
tag name.

  • return mixed | Collection | null
  • throws ChildNotFoundException
  • throws NotLoadedException
public hasChildren () : bool
 

Check if node have children nodes

  • return bool
  • throws NotLoadedException
public lastChild () : PHPHtmlParser\Dom\AbstractNode
 

Simple wrapper function that returns the last child.

  • return AbstractNode
  • throws ChildNotFoundException
  • throws NotLoadedException
public load ( string $str , array $options = [ ] ) : PHPHtmlParser\Dom
 

Attempts to load the dom from any resource, string, file, or URL.

  • return PHPHtmlParser\Dom
  • throws ChildNotFoundException
  • throws CircularException
  • throws CurlException
  • throws StrictException
public loadFromFile ( string $file , array $options = [ ] ) : PHPHtmlParser\Dom
 

Loads the dom from a document file/url

  • return PHPHtmlParser\Dom
  • throws ChildNotFoundException
  • throws CircularException
  • throws StrictException
  • throws LogicalException
public loadFromUrl ( string $url , array $options = [ ] , ? PHPHtmlParser\CurlInterface $curl = NULL ) : PHPHtmlParser\Dom
 

Use a curl interface implementation to attempt to load
the content from a url.

  • return PHPHtmlParser\Dom
  • throws ChildNotFoundException
  • throws CircularException
  • throws CurlException
  • throws StrictException
public loadStr ( string $str , array $option = [ ] ) : PHPHtmlParser\Dom
 

Parsers the html of the given string. Used for load(), loadFromFile(),
and loadFromUrl().

  • return PHPHtmlParser\Dom
  • throws ChildNotFoundException
  • throws CircularException
  • throws StrictException
public removeNoSlashTag ( $tag ) : PHPHtmlParser\Dom
 

Removes a tag from the list of no-slash tags.

public removeSelfClosingTag ( $tag ) : PHPHtmlParser\Dom
 

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

public setOptions ( array $options ) : PHPHtmlParser\Dom
 

Sets a global options array to be used by all load calls.

Properties
protected $content
 

The document string.

protected $defaultCharset
 

The charset we would like the output to be in.

  • var string
protected $globalOptions
 

A global options array to be used by all load calls.

  • var array
protected $noSlash
 

A list of tags where there should be no /> at the end (html5 style)

  • var array
protected $options
 

A persistent option object to be used for all options in the
parsing of the file.

protected $raw
 

The raw version of the document string.

  • var string
protected $rawSize
 

The original file size of the document.

  • var int
protected $selfClosing
 

A list of tags which will always be self closing

  • var array
protected $size
 

The size of the document after it is cleaned.

  • var int
Methods
protected clean ( string $str ) : string
 

Cleans the html of any none-html information.

  • return string
protected detectCharset () : bool
 

Attempts to detect the charset that the html was sent in.

  • return bool
  • throws ChildNotFoundException
protected isLoaded () : void
 

Checks if the load methods have been called.

  • throws NotLoadedException
protected parse () : void
 

Attempts to parse the html in content.

  • return void
  • throws ChildNotFoundException
  • throws CircularException
  • throws StrictException
protected parseTag () : array
 

Attempt to parse a tag out of the content.

  • return array
  • throws StrictException
© 2020 Bruce Wells
Search Namespaces \ Classes
Configuration Numbers (0-9.) only