Kotchasan

DOMParser
in package

Class for DOM Parsing.

Tags
see
https://www.kotchasan.com/

Table of Contents

$doms  : array<string|int, mixed>
Array of nodes.
__construct()  : mixed
Class constructor.
load()  : static
Parse HTML from URL.
nodes()  : array<string|int, mixed>
Get all nodes.
toHTML()  : string
Export the parsed HTML code as a string.
drawNode()  : string
Draw the node and its descendants recursively.
populate()  : mixed
Populate previousSibling and nextSibling for each node recursively.

Properties

$doms

Array of nodes.

protected array<string|int, mixed> $doms = []

Methods

__construct()

Class constructor.

public __construct(string $html[, string $charset = 'utf-8' ]) : mixed
Parameters
$html : string

HTML code.

$charset : string = 'utf-8'

Encoding (default utf-8).

Return values
mixed

load()

Parse HTML from URL.

public static load(string $url) : static
Parameters
$url : string

URL to parse.

Return values
static

nodes()

Get all nodes.

public nodes() : array<string|int, mixed>
Return values
array<string|int, mixed>

toHTML()

Export the parsed HTML code as a string.

public toHTML() : string
Return values
string

drawNode()

Draw the node and its descendants recursively.

private drawNode(DOMNode $node) : string
Parameters
$node : DOMNode

The node to draw.

Return values
string

The HTML representation of the node.

populate()

Populate previousSibling and nextSibling for each node recursively.

private populate(DOMNode $node) : mixed
Parameters
$node : DOMNode

The node to populate.

Return values
mixed

Search results