Domhtml
in package
implements
Iterator
Parse DOM data from HTML strings.
Tags
Interfaces, Classes, Traits and Enums
- Iterator
Table of Contents
- $dom : DOMDocument
- DOM object.
- $_iterator : array<string|int, mixed>
- Iterator status.
- $_origCharset : string
- Original charset of data.
- $_xmlencoding : string
- Encoding tag added to beginning of output.
- __construct() : mixed
- Constructor.
- current() : mixed
- getBody() : DOMElement
- Returns the BODY element, or creates one if it doesn't exist.
- getCharset() : string
- Get the charset of the DOM data.
- getHead() : DOMElement
- Returns the HEAD element, or creates one if it doesn't exist.
- key() : mixed
- next() : mixed
- returnBody() : string
- Returns the body text in the original charset.
- returnHtml() : string
- Returns the full HTML text in the original charset.
- rewind() : mixed
- valid() : mixed
- _loadHTML() : mixed
- Loads the HTML data.
Properties
$dom
DOM object.
public
DOMDocument
$dom
$_iterator
Iterator status.
protected
array<string|int, mixed>
$_iterator
= null
$_origCharset
Original charset of data.
protected
string
$_origCharset
$_xmlencoding
Encoding tag added to beginning of output.
protected
string
$_xmlencoding
= ''
Methods
__construct()
Constructor.
public
__construct(string $text[, string $charset = null ]) : mixed
Parameters
- $text : string
-
The text of the HTML document.
- $charset : string = null
-
The charset of the HTML document.
Tags
Return values
mixed —current()
public
current() : mixed
Return values
mixed —getBody()
Returns the BODY element, or creates one if it doesn't exist.
public
getBody() : DOMElement
Tags
Return values
DOMElement —BODY element.
getCharset()
Get the charset of the DOM data.
public
getCharset() : string
Tags
Return values
string —Charset of DOM data.
getHead()
Returns the HEAD element, or creates one if it doesn't exist.
public
getHead() : DOMElement
Return values
DOMElement —HEAD element.
key()
public
key() : mixed
Return values
mixed —next()
public
next() : mixed
Return values
mixed —returnBody()
Returns the body text in the original charset.
public
returnBody() : string
Return values
string —HTML text.
returnHtml()
Returns the full HTML text in the original charset.
public
returnHtml([array<string|int, mixed> $opts = [] ]) : string
Parameters
- $opts : array<string|int, mixed> = []
-
Additional options: (since 2.1.0)
- charset: (string) Return using this charset. If set but empty, will return as currently stored in the DOM object.
- metacharset: (boolean) If true, will add a META tag containing the charset information.
Return values
string —HTML text.
rewind()
public
rewind() : mixed
Return values
mixed —valid()
public
valid() : mixed
Return values
mixed —_loadHTML()
Loads the HTML data.
protected
_loadHTML(string $html) : mixed
Parameters
- $html : string
-
HTML data.