-
Notifications
You must be signed in to change notification settings - Fork 4
API Reference
PeratX edited this page Feb 22, 2017
·
8 revisions
Type | Name | Description |
---|---|---|
object | SimpleHtmlDom::initDomFromString(string $content) | Creates a DOM object from a string. |
object | SimpleHtmlDom::initDomFromFile(string $filename) | Creates a DOM object from a file or a URL. |
Type | Name | Description |
---|---|---|
void | __construct(string $filename) | Constructor, set the filename parameter will automatically load the contents, either text or file/url. |
string | plaintext | Returns the contents extracted from HTML. |
void | clear() | Clean up memory. |
void | load(string $content) | Load contents from a string. |
string | save([string $filename]) | Dumps the internal DOM tree back into a string. If the $filename is set, result string will save to file. |
void | loadFile(string $filename) | Load contents from a from a file or a URL. |
void | setCallback(callable $callback) | Set a callback function. |
mixed | find(string $selector[, int $index]) | Find elements by the CSS selector. Returns the Nth element object if index is set, otherwise return an array of object. |
Type | Name | Description |
---|---|---|
string | [attribute] | Read or write element's attribure value. |
string | tag | Read or write the tag name of element. |
string | outerText | Read or write the outer HTML text of element. |
string | innerText | Read or write the inner HTML text of element. |
string | plaintext | Read or write the plain text of element. |
mixed | find(string $selector[, int $index]) | Find children by the CSS selector. Returns the Nth element object if index is set, otherwise, return an array of object. |
Type | Name | Description |
---|---|---|
mixed | $e->children([int $index]) | Returns the Nth child object if index is set, otherwise return an array of children. |
element | $e->parent() | Returns the parent of element. |
element | $e->firstChild() | Returns the first child of element, or null if not found. |
element | $e->lastChild() | Returns the last child of element, or null if not found. |
element | $e->nextSibling() | Returns the next sibling of element, or null if not found. |
element | $e->prevSibling() | Returns the previous sibling of element, or null if not found. |
Type | Method | Mapping |
---|---|---|
array | $e->getAllAttributes() | $e->attr |
string | $e->getAttribute($name) | $e->attribute |
void | $e->setAttribute($name, $value) | $value = $e->attribute |
bool | $e->hasAttribute($name) | isset($e->attribute) |
void | $e->removeAttribute($name) | $e->attribute = null |
element | $e->getElementById($id) | $e->find("#$id", 0) |
mixed | $e->getElementsById($id[, $index]) | $e->find("#$id"[, int $index]) |
element | $e->getElementByTagName($name) | $e->find($name, 0) |
mixed | $e->getElementsByTagName($name[, $index]) | $e->find($name[, int $index]) |
element | $e->parentNode() | $e->parent() |
mixed | $e->childNodes([$index]) | $e->children([int $index]) |