Simple Html Dom Parser for PHP
DomParser API
### SimpleHtmlDomNode (group of dom elements) API
### SimpleHtmlDom (single dom element) API
---
## find(string $selector, int|null $idx): mixed
↑
Find list of nodes with a CSS selector.
**Parameters:**
- `string $selector`
- `int|null $idx`
**Return:**
- `mixed`
--------
## findMulti(string $selector): mixed
↑
Find nodes with a CSS selector.
**Parameters:**
- `string $selector`
**Return:**
- `mixed`
--------
## findMultiOrFalse(string $selector): mixed
↑
Find nodes with a CSS selector or false, if no element is found.
**Parameters:**
- `string $selector`
**Return:**
- `mixed`
--------
## findOne(string $selector): static
↑
Find one node with a CSS selector.
**Parameters:**
- `string $selector`
**Return:**
- `static`
--------
## findOneOrFalse(string $selector): mixed
↑
Find one node with a CSS selector or false, if no element is found.
**Parameters:**
- `string $selector`
**Return:**
- `mixed`
--------
## fixHtmlOutput(string $content, bool $multiDecodeNewHtmlEntity): string
↑
**Parameters:**
- `string $content`
- `bool $multiDecodeNewHtmlEntity`
**Return:**
- `string`
--------
## getDocument(): DOMDocument
↑
**Parameters:**
__nothing__
**Return:**
- `\DOMDocument`
--------
## getElementByClass(string $class): mixed
↑
Return elements by ".class".
**Parameters:**
- `string $class`
**Return:**
- `mixed`
--------
## getElementById(string $id): mixed
↑
Return element by #id.
**Parameters:**
- `string $id`
**Return:**
- `mixed`
--------
## getElementByTagName(string $name): mixed
↑
Return element by tag name.
**Parameters:**
- `string $name`
**Return:**
- `mixed`
--------
## getElementsById(string $id, int|null $idx): mixed
↑
Returns elements by "#id".
**Parameters:**
- `string $id`
- `int|null $idx`
**Return:**
- `mixed`
--------
## getElementsByTagName(string $name, int|null $idx): mixed
↑
Returns elements by tag name.
**Parameters:**
- `string $name`
- `int|null $idx`
**Return:**
- `mixed`
--------
## html(bool $multiDecodeNewHtmlEntity): string
↑
Get dom node's outer html.
**Parameters:**
- `bool $multiDecodeNewHtmlEntity`
**Return:**
- `string`
--------
## innerHtml(bool $multiDecodeNewHtmlEntity): string
↑
Get dom node's inner html.
**Parameters:**
- `bool $multiDecodeNewHtmlEntity`
**Return:**
- `string`
--------
## innerXml(bool $multiDecodeNewHtmlEntity): string
↑
Get dom node's inner xml.
**Parameters:**
- `bool $multiDecodeNewHtmlEntity`
**Return:**
- `string`
--------
## loadHtml(string $html, int|null $libXMLExtraOptions): DomParserInterface
↑
Load HTML from string.
**Parameters:**
- `string $html`
- `int|null $libXMLExtraOptions`
**Return:**
- `\DomParserInterface`
--------
## loadHtmlFile(string $filePath, int|null $libXMLExtraOptions): DomParserInterface
↑
Load HTML from file.
**Parameters:**
- `string $filePath`
- `int|null $libXMLExtraOptions`
**Return:**
- `\DomParserInterface`
--------
## save(string $filepath): string
↑
Save the html-dom as string.
**Parameters:**
- `string $filepath`
**Return:**
- `string`
--------
## set_callback(callable $functionName): mixed
↑
**Parameters:**
- `callable $functionName`
**Return:**
- `mixed`
--------
## text(bool $multiDecodeNewHtmlEntity): string
↑
Get dom node's plain text.
**Parameters:**
- `bool $multiDecodeNewHtmlEntity`
**Return:**
- `string`
--------
## xml(bool $multiDecodeNewHtmlEntity, bool $htmlToXml, bool $removeXmlHeader, int $options): string
↑
Get the HTML as XML or plain XML if needed.
**Parameters:**
- `bool $multiDecodeNewHtmlEntity`
- `bool $htmlToXml`
- `bool $removeXmlHeader`
- `int $options`
**Return:**
- `string`
--------
## count(): int
↑
Get the number of items in this dom node.
**Parameters:**
__nothing__
**Return:**
- `int`
--------
## find(string $selector, int $idx): SimpleHtmlDomNode|\SimpleHtmlDomNode[]|null
↑
Find list of nodes with a CSS selector.
**Parameters:**
- `string $selector`
- `int $idx`
**Return:**
- `\SimpleHtmlDomNode|\SimpleHtmlDomNode[]|null`
--------
## findMulti(string $selector): SimpleHtmlDomInterface[]|\SimpleHtmlDomNodeInterface
↑
Find nodes with a CSS selector.
**Parameters:**
- `string $selector`
**Return:**
- `\SimpleHtmlDomInterface[]|\SimpleHtmlDomNodeInterface`
--------
## findMultiOrFalse(string $selector): false|\SimpleHtmlDomInterface[]|\SimpleHtmlDomNodeInterface
↑
Find nodes with a CSS selector or false, if no element is found.
**Parameters:**
- `string $selector`
**Return:**
- `false|\SimpleHtmlDomInterface[]|\SimpleHtmlDomNodeInterface`
--------
## findOne(string $selector): SimpleHtmlDomNode|null
↑
Find one node with a CSS selector.
**Parameters:**
- `string $selector`
**Return:**
- `\SimpleHtmlDomNode|null`
--------
## findOneOrFalse(string $selector): false|\SimpleHtmlDomNode
↑
Find one node with a CSS selector or false, if no element is found.
**Parameters:**
- `string $selector`
**Return:**
- `false|\SimpleHtmlDomNode`
--------
## innerHtml(): string[]
↑
Get html of elements.
**Parameters:**
__nothing__
**Return:**
- `string[]`
--------
## innertext(): string[]
↑
alias for "$this->innerHtml()" (added for compatibly-reasons with v1.x)
**Parameters:**
__nothing__
**Return:**
- `string[]`
--------
## outertext(): string[]
↑
alias for "$this->innerHtml()" (added for compatibly-reasons with v1.x)
**Parameters:**
__nothing__
**Return:**
- `string[]`
--------
## text(): string[]
↑
Get plain text.
**Parameters:**
__nothing__
**Return:**
- `string[]`
--------
## childNodes(int $idx): SimpleHtmlDomInterface|\SimpleHtmlDomInterface[]|\SimpleHtmlDomNodeInterface|null
↑
Returns children of node.
**Parameters:**
- `int $idx`
**Return:**
- `\SimpleHtmlDomInterface|\SimpleHtmlDomInterface[]|\SimpleHtmlDomNodeInterface|null`
--------
## delete(): mixed
↑
Delete
**Parameters:**
__nothing__
**Return:**
- `mixed`
--------
## find(string $selector, int|null $idx): SimpleHtmlDomInterface|\SimpleHtmlDomInterface[]|\SimpleHtmlDomNodeInterface
↑
Find list of nodes with a CSS selector.
**Parameters:**
- `string $selector`
- `int|null $idx`
**Return:**
- `\SimpleHtmlDomInterface|\SimpleHtmlDomInterface[]|\SimpleHtmlDomNodeInterface`
--------
## findMulti(string $selector): SimpleHtmlDomInterface[]|\SimpleHtmlDomNodeInterface
↑
Find nodes with a CSS selector.
**Parameters:**
- `string $selector`
**Return:**
- `\SimpleHtmlDomInterface[]|\SimpleHtmlDomNodeInterface`
--------
## findMultiOrFalse(string $selector): false|\SimpleHtmlDomInterface[]|\SimpleHtmlDomNodeInterface
↑
Find nodes with a CSS selector or false, if no element is found.
**Parameters:**
- `string $selector`
**Return:**
- `false|\SimpleHtmlDomInterface[]|\SimpleHtmlDomNodeInterface`
--------
## findOne(string $selector): SimpleHtmlDomInterface
↑
Find one node with a CSS selector.
**Parameters:**
- `string $selector`
**Return:**
- `\SimpleHtmlDomInterface`
--------
## findOneOrFalse(string $selector): false|\SimpleHtmlDomInterface
↑
Find one node with a CSS selector or false, if no element is found.
**Parameters:**
- `string $selector`
**Return:**
- `false|\SimpleHtmlDomInterface`
--------
## firstChild(): SimpleHtmlDomInterface|null
↑
Returns the first child of node.
**Parameters:**
__nothing__
**Return:**
- `\SimpleHtmlDomInterface|null`
--------
## getAllAttributes(): string[]|null
↑
Returns an array of attributes.
**Parameters:**
__nothing__
**Return:**
- `string[]|null`
--------
## getAttribute(string $name): string
↑
Return attribute value.
**Parameters:**
- `string $name`
**Return:**
- `string`
--------
## getElementByClass(string $class): SimpleHtmlDomInterface[]|\SimpleHtmlDomNodeInterface
↑
Return elements by ".class".
**Parameters:**
- `string $class`
**Return:**
- `\SimpleHtmlDomInterface[]|\SimpleHtmlDomNodeInterface`
--------
## getElementById(string $id): SimpleHtmlDomInterface
↑
Return element by "#id".
**Parameters:**
- `string $id`
**Return:**
- `\SimpleHtmlDomInterface`
--------
## getElementByTagName(string $name): SimpleHtmlDomInterface
↑
Return element by tag name.
**Parameters:**
- `string $name`
**Return:**
- `\SimpleHtmlDomInterface`
--------
## getElementsById(string $id, int|null $idx): SimpleHtmlDomInterface|\SimpleHtmlDomInterface[]|\SimpleHtmlDomNodeInterface
↑
Returns elements by "#id".
**Parameters:**
- `string $id`
- `int|null $idx`
**Return:**
- `\SimpleHtmlDomInterface|\SimpleHtmlDomInterface[]|\SimpleHtmlDomNodeInterface`
--------
## getElementsByTagName(string $name, int|null $idx): SimpleHtmlDomInterface|\SimpleHtmlDomInterface[]|\SimpleHtmlDomNodeInterface
↑
Returns elements by tag name.
**Parameters:**
- `string $name`
- `int|null $idx`
**Return:**
- `\SimpleHtmlDomInterface|\SimpleHtmlDomInterface[]|\SimpleHtmlDomNodeInterface`
--------
## getHtmlDomParser(): HtmlDomParser
↑
Create a new "HtmlDomParser"-object from the current context.
**Parameters:**
__nothing__
**Return:**
- `\HtmlDomParser`
--------
## getIterator(): SimpleHtmlDomNodeInterface
↑
Retrieve an external iterator.
**Parameters:**
__nothing__
**Return:**
- `\SimpleHtmlDomNodeInterface
An instance of an object implementing Iterator or
Traversable
`
--------
## getNode(): DOMNode
↑
**Parameters:**
__nothing__
**Return:**
- `\DOMNode`
--------
## getTag(): string
↑
Return the tag of node
**Parameters:**
__nothing__
**Return:**
- `string`
--------
## hasAttribute(string $name): bool
↑
Determine if an attribute exists on the element.
**Parameters:**
- `string $name`
**Return:**
- `bool`
--------
## html(bool $multiDecodeNewHtmlEntity): string
↑
Get dom node's outer html.
**Parameters:**
- `bool $multiDecodeNewHtmlEntity`
**Return:**
- `string`
--------
## innerHtml(bool $multiDecodeNewHtmlEntity): string
↑
Get dom node's inner html.
**Parameters:**
- `bool $multiDecodeNewHtmlEntity`
**Return:**
- `string`
--------
## innerXml(bool $multiDecodeNewHtmlEntity): string
↑
Get dom node's inner html.
**Parameters:**
- `bool $multiDecodeNewHtmlEntity`
**Return:**
- `string`
--------
## isRemoved(): bool
↑
Nodes can get partially destroyed in which they're still an
actual DOM node (such as \DOMElement) but almost their entire
body is gone, including the `nodeType` attribute.
**Parameters:**
__nothing__
**Return:**
- `bool true if node has been destroyed`
--------
## lastChild(): SimpleHtmlDomInterface|null
↑
Returns the last child of node.
**Parameters:**
__nothing__
**Return:**
- `\SimpleHtmlDomInterface|null`
--------
## nextNonWhitespaceSibling(): SimpleHtmlDomInterface|null
↑
Returns the next sibling of node, and it will ignore whitespace elements.
**Parameters:**
__nothing__
**Return:**
- `\SimpleHtmlDomInterface|null`
--------
## nextSibling(): SimpleHtmlDomInterface|null
↑
Returns the next sibling of node.
**Parameters:**
__nothing__
**Return:**
- `\SimpleHtmlDomInterface|null`
--------
## parentNode(): SimpleHtmlDomInterface
↑
Returns the parent of node.
**Parameters:**
__nothing__
**Return:**
- `\SimpleHtmlDomInterface`
--------
## previousNonWhitespaceSibling(): SimpleHtmlDomInterface|null
↑
Returns the previous sibling of node, and it will ignore whitespace elements.
**Parameters:**
__nothing__
**Return:**
- `\SimpleHtmlDomInterface|null`
--------
## previousSibling(): SimpleHtmlDomInterface|null
↑
Returns the previous sibling of node.
**Parameters:**
__nothing__
**Return:**
- `\SimpleHtmlDomInterface|null`
--------
## removeAttribute(string $name): SimpleHtmlDomInterface
↑
Remove attribute.
**Parameters:**
- `string $name
The name of the html-attribute.
`
**Return:**
- `\SimpleHtmlDomInterface`
--------
## removeAttributes(): SimpleHtmlDomInterface
↑
Remove all attributes
**Parameters:**
__nothing__
**Return:**
- `\SimpleHtmlDomInterface`
--------
## setAttribute(string $name, string|null $value, bool $strictEmptyValueCheck): SimpleHtmlDomInterface
↑
Set attribute value.
**Parameters:**
- `string $name
The name of the html-attribute.
`
- `string|null $value
Set to NULL or empty string, to remove the attribute.
`
- `bool $strictEmptyValueCheck
$value must be NULL, to remove the attribute,
so that you can set an empty string as attribute-value e.g. autofocus=""
`
Return:
text(): string
↑
Get dom node's plain text.
Parameters:
nothing
Return:
val(string|string[]|null $value): string|string[]|null
↑
Parameters:
string|string[]|null $value <p>
null === get the current input value
text === set a new input value
</p>
Return: