Documentation

simple_html_dom_node
in package

simple html dom node PaperG - added ability for "find" routine to lowercase the value of the selector.

PaperG - added $tag_start to track the start position of the tag in the total byte index

Table of Contents

$_  : mixed
$attr  : array<string|int, mixed>
List of attributes
$children  : array<string|int, mixed>
List of child node objects
$nodes  : mixed
$nodetype  : int
Node type
$parent  : object|null
The parent node object
$tag  : string
Tag name
$tag_start  : int
Start position of the tag in the document
$dom  : object|null
The DOM object
__construct()  : mixed
Construct new node object
__destruct()  : mixed
__get()  : mixed
__isset()  : mixed
__set()  : mixed
__toString()  : mixed
__unset()  : mixed
appendChild()  : mixed
childNodes()  : mixed
children()  : object|array<string|int, mixed>|null
Get child node at specified index
clear()  : mixed
convert_text()  : mixed
dump()  : mixed
dump_node()  : mixed
find()  : mixed
find_ancestor_tag()  : object|null
Traverse ancestors to the first matching tag.
first_child()  : object|null
Get first child node
firstChild()  : mixed
get_display_size()  : array<string|int, mixed>
Function to try a few tricks to determine the displayed size of an img on the page.
getAllAttributes()  : mixed
getAttribute()  : mixed
getElementById()  : mixed
getElementByTagName()  : mixed
getElementsById()  : mixed
getElementsByTagName()  : mixed
has_child()  : bool
hasAttribute()  : mixed
hasChildNodes()  : mixed
innertext()  : string
Get node's inner text (everything inside the opening and closing tags)
is_utf8()  : bool
Returns true if $string is valid UTF-8 and false otherwise.
last_child()  : object|null
Get last child node
lastChild()  : mixed
makeup()  : mixed
next_sibling()  : object|null
Get next sibling node
nextSibling()  : mixed
nodeName()  : mixed
outertext()  : string
Get node's outer text (everything including the opening and closing tags)
parent()  : object|null
Return or set parent node
parentNode()  : mixed
prev_sibling()  : object|null
Get previous sibling node
previousSibling()  : mixed
removeAttribute()  : mixed
setAttribute()  : mixed
text()  : string
Get node's plain text (everything excluding all tags)
xmltext()  : string
Get node's xml text (inner text as a CDATA section)
match()  : mixed
parse_selector()  : mixed
seek()  : mixed

Properties

$attr

List of attributes

public array<string|int, mixed> $attr = array()

$children

List of child node objects

public array<string|int, mixed> $children = array()

$tag_start

Start position of the tag in the document

public int $tag_start = 0

Methods

__construct()

Construct new node object

public __construct(mixed $dom) : mixed

Adds itself to the list of DOM Nodes simple_html_dom::$nodes

Parameters
$dom : mixed
Return values
mixed

__get()

public __get(mixed $name) : mixed
Parameters
$name : mixed
Return values
mixed

__isset()

public __isset(mixed $name) : mixed
Parameters
$name : mixed
Return values
mixed

__set()

public __set(mixed $name, mixed $value) : mixed
Parameters
$name : mixed
$value : mixed
Return values
mixed

__unset()

public __unset(mixed $name) : mixed
Parameters
$name : mixed
Return values
mixed

appendChild()

public appendChild(mixed $node) : mixed
Parameters
$node : mixed
Return values
mixed

childNodes()

public childNodes([mixed $idx = -1 ]) : mixed
Parameters
$idx : mixed = -1
Return values
mixed

children()

Get child node at specified index

public children([int $idx = -1 ]) : object|array<string|int, mixed>|null
Parameters
$idx : int = -1

The index of the child node to return, -1 to return all child nodes.

Return values
object|array<string|int, mixed>|null

The child node at the specified index, all child nodes or null if the index is invalid.

convert_text()

public convert_text(mixed $text) : mixed
Parameters
$text : mixed
Return values
mixed

dump()

public dump([mixed $show_attr = true ], mixed $deep) : mixed
Parameters
$show_attr : mixed = true
$deep : mixed
Return values
mixed

dump_node()

public dump_node([mixed $echo = true ]) : mixed
Parameters
$echo : mixed = true
Return values
mixed

find()

public find(mixed $selector[, mixed $idx = null ][, mixed $lowercase = false ]) : mixed
Parameters
$selector : mixed
$idx : mixed = null
$lowercase : mixed = false
Return values
mixed

find_ancestor_tag()

Traverse ancestors to the first matching tag.

public find_ancestor_tag(string $tag) : object|null
Parameters
$tag : string

Tag to find

Tags
todo

Null is returned implicitly by calling ->parent on the root node. This behaviour could change at any time, rendering this function invalid.

Return values
object|null

First matching node in the DOM tree or null if no match was found.

first_child()

Get first child node

public first_child() : object|null
Tags
todo

Use empty() instead of count() to improve performance on large arrays.

Return values
object|null

The first child node or null if the current node has no child nodes.

get_display_size()

Function to try a few tricks to determine the displayed size of an img on the page.

public get_display_size() : array<string|int, mixed>

NOTE: This will ONLY work on an IMG tag. Returns FALSE on all other tag types.

Tags
author

John Schlick

Return values
array<string|int, mixed>

an array containing the 'height' and 'width' of the image on the page or -1 if we can't figure it out.

getAllAttributes()

public getAllAttributes() : mixed
Return values
mixed

getAttribute()

public getAttribute(mixed $name) : mixed
Parameters
$name : mixed
Return values
mixed

getElementById()

public getElementById(mixed $id) : mixed
Parameters
$id : mixed
Return values
mixed

getElementByTagName()

public getElementByTagName(mixed $name) : mixed
Parameters
$name : mixed
Return values
mixed

getElementsById()

public getElementsById(mixed $id[, mixed $idx = null ]) : mixed
Parameters
$id : mixed
$idx : mixed = null
Return values
mixed

getElementsByTagName()

public getElementsByTagName(mixed $name[, mixed $idx = null ]) : mixed
Parameters
$name : mixed
$idx : mixed = null
Return values
mixed

has_child()

public has_child() : bool
Return values
bool

True if the node has at least one child node

hasAttribute()

public hasAttribute(mixed $name) : mixed
Parameters
$name : mixed
Return values
mixed

hasChildNodes()

public hasChildNodes() : mixed
Return values
mixed

innertext()

Get node's inner text (everything inside the opening and closing tags)

public innertext() : string
Return values
string

is_utf8()

Returns true if $string is valid UTF-8 and false otherwise.

public static is_utf8(mixed $str) : bool
Parameters
$str : mixed

String to be tested

Return values
bool

last_child()

Get last child node

public last_child() : object|null
Tags
todo

Use end() to slightly improve performance on large arrays.

Return values
object|null

The last child node or null if the current node has no child nodes.

next_sibling()

Get next sibling node

public next_sibling() : object|null
Return values
object|null

The sibling node or null if the current node has no sibling nodes.

nextSibling()

public nextSibling() : mixed
Return values
mixed

outertext()

Get node's outer text (everything including the opening and closing tags)

public outertext() : string
Return values
string

parent()

Return or set parent node

public parent([object|null $parent = null ]) : object|null
Parameters
$parent : object|null = null

(optional) The parent node, null to return the current parent node.

Return values
object|null

The parent node

prev_sibling()

Get previous sibling node

public prev_sibling() : object|null
Return values
object|null

The sibling node or null if the current node has no sibling nodes.

previousSibling()

public previousSibling() : mixed
Return values
mixed

removeAttribute()

public removeAttribute(mixed $name) : mixed
Parameters
$name : mixed
Return values
mixed

setAttribute()

public setAttribute(mixed $name, mixed $value) : mixed
Parameters
$name : mixed
$value : mixed
Return values
mixed

text()

Get node's plain text (everything excluding all tags)

public text() : string
Return values
string

xmltext()

Get node's xml text (inner text as a CDATA section)

public xmltext() : string
Return values
string

match()

protected match(mixed $exp, mixed $pattern, mixed $value) : mixed
Parameters
$exp : mixed
$pattern : mixed
$value : mixed
Return values
mixed

parse_selector()

protected parse_selector(mixed $selector_string) : mixed
Parameters
$selector_string : mixed
Return values
mixed

seek()

protected seek(mixed $selector, mixed &$ret[, mixed $lowercase = false ]) : mixed
Parameters
$selector : mixed
$ret : mixed
$lowercase : mixed = false
Return values
mixed

Search results