DOMNode
in package
Class representing a DOM Node.
Tags
Table of Contents
- $attributes : array<string|int, mixed>
- List of node attributes.
- $childNodes : array<string|int, mixed>
- List of child nodes.
- $level : int
- Node level. The outermost level is 0.
- $nextSibling : DOMNode
- Next sibling node. If it's the last node, it will be null.
- $nodeName : mixed
- Node name.
- $nodeValue : string|null
- Node value. It will be null if the node is a tag.
- $parentNode : DOMNode
- Parent node.
- $previousSibling : DOMNode
- Previous sibling node. If it's the first node, it will be null.
- __construct() : mixed
- Class constructor.
- hasChildNodes() : bool
- Check if the node has child nodes.
- hasClass() : bool
- Check if the node has a specific class.
- isInlineElement() : bool
- Check if the element is an inline element.
- nodeText() : string
- Get the concatenated text content of the node and its descendants.
- unentities() : string
- Convert HTML entities to their corresponding characters.
Properties
$attributes
List of node attributes.
public
array<string|int, mixed>
$attributes
= []
$childNodes
List of child nodes.
public
array<string|int, mixed>
$childNodes
$level
Node level. The outermost level is 0.
public
int
$level
$nextSibling
Next sibling node. If it's the last node, it will be null.
public
DOMNode
$nextSibling
$nodeName
Node name.
public
mixed
$nodeName
$nodeValue
Node value. It will be null if the node is a tag.
public
string|null
$nodeValue
$parentNode
Parent node.
public
DOMNode
$parentNode
$previousSibling
Previous sibling node. If it's the first node, it will be null.
public
DOMNode
$previousSibling
Methods
__construct()
Class constructor.
public
__construct(string $nodeName, DOMNode|null $parentNode, array<string|int, mixed> $attributes[, string|null $nodeValue = null ]) : mixed
Parameters
- $nodeName : string
-
The tag name. If there is no tag name, it represents empty text.
- $parentNode : DOMNode|null
-
The parent node. If it's the first node, it will be null.
- $attributes : array<string|int, mixed>
-
The node attributes (properties).
- $nodeValue : string|null = null
-
The text content of the node. It will be null if the node is a tag.
Return values
mixed —hasChildNodes()
Check if the node has child nodes.
public
hasChildNodes() : bool
Return values
bool —True if it has child nodes, false otherwise.
hasClass()
Check if the node has a specific class.
public
hasClass(string $className) : bool
Parameters
- $className : string
-
The class name to check.
Return values
bool —True if it has the class, false otherwise.
isInlineElement()
Check if the element is an inline element.
public
isInlineElement() : bool
Return values
bool —True if it's an inline element, false if it's a block-level element.
nodeText()
Get the concatenated text content of the node and its descendants.
public
nodeText() : string
Return values
string —The concatenated text content.
unentities()
Convert HTML entities to their corresponding characters.
public
unentities(string $html) : string
Parameters
- $html : string
-
The HTML string to convert.
Return values
string —The converted string.