tags
$es = $html->find('div div div');
```
```PHP
// Find all
in which class=hello
$es = $html->find('table.hello td');
```
```PHP
// Find all td tags with attribite align=center in table tags
$es = $html->find('table td[align=center]');
```
```PHP
// Find all text blocks
$es = $html->find('text');
```
```PHP
// Find all comment () blocks
$es = $html->find('comment');
```
--------------------------------
### PHP Simple HTML DOM Parser Element Object API
Source: https://github.com/yuzdzhan/htmltodocx/blob/master/simplehtmldom/manual/manual_api.htm
Methods and properties for reading, writing, and traversing individual HTML elements.
```APIDOC
[attribute]: string
Description: Reads or writes the element's attribute value.
tag: string
Description: Reads or writes the tag name of the element.
outertext: string
Description: Reads or writes the outer HTML text of the element.
innertext: string
Description: Reads or writes the inner HTML text of the element.
plaintext: string
Description: Reads or writes the plain text of the element.
find(selector: string, index: int = null): mixed
selector: The CSS selector to find children by.
index: Optional. If set, returns the Nth element object.
Returns: The Nth element object if index is set, otherwise an array of objects.
```
--------------------------------
### PHP Simple HTML DOM Parser DOM Traversing API
Source: https://github.com/yuzdzhan/htmltodocx/blob/master/simplehtmldom/manual/manual_api.htm
Methods for navigating the DOM tree relative to an element.
```APIDOC
$e->children(index: int = null): mixed
index: Optional. If set, returns the Nth child object.
Returns: The Nth child object if index is set, otherwise an array of children.
$e->parent(): element
Returns: The parent of the element.
$e->first_child(): element
Returns: The first child of the element, or null if not found.
$e->last_child(): element
Returns: The last child of the element, or null if not found.
$e->next_sibling(): element
Returns: The next sibling of the element, or null if not found.
$e->prev_sibling(): element
Returns: The previous sibling of the element, or null if not found.
```
--------------------------------
### PHP Simple HTML DOM Parser Camel Case Method Mappings
Source: https://github.com/yuzdzhan/htmltodocx/blob/master/simplehtmldom/manual/manual_api.htm
Mapping of W3C standard camel naming conventions to the PHP Simple HTML DOM Parser's internal snake_case methods.
```APIDOC
$e->getAllAttributes() -> $e->attr: array
$e->getAttribute(name: string) -> $e->attribute: string
$e->setAttribute(name: string, value: string) -> $e->attribute = $value: void
$e->hasAttribute(name: string) -> isset($e->attribute): bool
$e->removeAttribute(name: string) -> $e->attribute = null: void
$e->getElementById(id: string) -> $e->find("#$id", 0): element
$e->getElementsById(id: string, index: int = null) -> $e->find("#$id", index): mixed
$e->getElementByTagName(name: string) -> $e->find($name, 0): element
$e->getElementsByTagName(name: string, index: int = null) -> $e->find($name, index): mixed
$e->parentNode() -> $e->parent(): element
$e->childNodes(index: int = null) -> $e->children(index): mixed
$e->firstChild() -> $e->first_child(): element
$e->lastChild() -> $e->last_child(): element
$e->nextSibling() -> $e->next_sibling(): element
$e->previousSibling() -> $e->prev_sibling(): element
```
--------------------------------
### PHP Simple HTML DOM Parser: Accessing URLs Behind a Proxy
Source: https://github.com/yuzdzhan/htmltodocx/blob/master/simplehtmldom/manual/manual_faq.htm
This solution shows how to configure PHP's stream context to enable `file_get_html()` to access URLs when the server is operating behind an HTTP proxy. It defines proxy settings within the stream context, allowing the parser to fetch content through the specified proxy.
```PHP
$context = array
(
'http' => array
(
'proxy' => 'addresseproxy:portproxy', // This needs to be the server and the port of the NTLM Authentication Proxy Server.
'request_fulluri' => true,
),
);
$context = stream_context_create($context);
$html= file_get_html('http://www.php.net', false, $context);
// ...
```
--------------------------------
### PHP Simple HTML DOM Parser DOM Object API
Source: https://github.com/yuzdzhan/htmltodocx/blob/master/simplehtmldom/manual/manual_api.htm
Methods and properties available on the main DOM object for loading, saving, manipulating, and querying HTML content.
```APIDOC
__construct(filename: string = null): void
filename: Optional. The filename or URL to load content from upon construction.
plaintext: string
Description: Returns the plain text content extracted from the HTML.
clear(): void
Description: Cleans up memory used by the DOM object.
load(content: string): void
content: The HTML content as a string to load into the DOM object.
save(filename: string = null): string
filename: Optional. If set, the result string will be saved to this file.
Returns: The internal DOM tree dumped back into a string.
load_file(filename: string): void
filename: The path to the file or a URL to load content from.
set_callback(function_name: string): void
function_name: The name of the callback function to set.
find(selector: string, index: int = null): mixed
selector: The CSS selector to find elements by.
index: Optional. If set, returns the Nth element object.
Returns: The Nth element object if index is set, otherwise an array of objects.
```
--------------------------------
### PHP: Find HTML Elements with Advanced Selectors
Source: https://github.com/yuzdzhan/htmltodocx/blob/master/simplehtmldom/manual/manual.htm
This PHP snippet demonstrates more advanced usage of the `find()` method, including CSS-like selectors. It shows how to find elements by ID (`#foo`), by class (`.foo`), by any element with a specific attribute (`*[id]`), and by multiple tag or attribute selectors combined (`a, img` or `a[title], img[title]`).
```php
// Find all element which id=foo
$ret = $html->find('#foo');
// Find all element which class=foo
$ret = $html->find('.foo');
// Find all element has attribute id
$ret = $html->find('*[id]');
// Find all anchors and images
$ret = $html->find('a, img');
// Find all anchors and images with the "title" attribute
$ret = $html->find('a[title], img[title]');
```
--------------------------------
### PHP: Find HTML Elements with Basic Selectors
Source: https://github.com/yuzdzhan/htmltodocx/blob/master/simplehtmldom/manual/manual.htm
This PHP snippet illustrates basic usage of the `find()` method to locate HTML elements. It covers finding all elements of a specific tag, finding the Nth or last element, and finding elements based on the presence or exact value of an ID attribute.
```php
// Find all anchors, returns a array of element objects
$ret = $html->find('a');
// Find (N)th anchor, returns element object or null if not found (zero based)
$ret = $html->find('a', 0);
// Find lastest anchor, returns element object or null if not found (zero based)
$ret = $html->find('a', -1);
// Find all with the id attribute
$ret = $html->find('div[id]');
// Find all which attribute id=foo
$ret = $html->find('div[id=foo]');
```
--------------------------------
### JavaScript: Initialize jQuery UI Tabs for Manual Sections
Source: https://github.com/yuzdzhan/htmltodocx/blob/master/simplehtmldom/manual/manual.htm
This JavaScript snippet uses jQuery to initialize tab functionality for various sections within the PHP Simple HTML DOM Parser manual. It targets specific `div` containers by their IDs and applies the `tabs()` method to their unordered lists.
```javascript
$(document).ready(function(){ $(function() {$('#container_quickstart > ul').tabs();}); $(function() {$('#container_create > ul').tabs();}); $(function() {$('#container_find > ul').tabs();}); $(function() {$('#container_access > ul').tabs();}); $(function() {$('#container_traverse > ul').tabs();}); $(function() {$('#container_dump > ul').tabs();}); $(function() {$('#container_callback > ul').tabs();}); });
```
--------------------------------
### Setting a Callback Function for HTML Processing in PHP
Source: https://github.com/yuzdzhan/htmltodocx/blob/master/simplehtmldom/manual/manual.htm
This PHP code snippet illustrates the usage of the `set_callback` method to register a custom function that will be invoked during the HTML dumping process. This allows developers to inject custom logic or transformations before the final HTML output is generated.
```PHP
$html->set_callback('my_callback');
// Callback function will be invoked while dumping
echo $html;
```
--------------------------------
### PHP Simple HTML DOM Parser: Quoting Selectors with Blanks
Source: https://github.com/yuzdzhan/htmltodocx/blob/master/simplehtmldom/manual/manual_faq.htm
This snippet demonstrates the correct way to quote selectors in the `find()` method when they contain blank spaces, ensuring elements are properly located. It addresses issues where elements might not be found due to unquoted spaces in attribute values.
```PHP
$html->find('div[style="padding: 0px 2px;"] span[class=rf]');
```
--------------------------------
### Special Element Attributes Reference
Source: https://github.com/yuzdzhan/htmltodocx/blob/master/simplehtmldom/manual/manual.htm
Documentation for special 'magic' attributes that allow reading or writing core properties of an HTML element, such as its tag name, outer HTML, inner HTML, and plain text content.
```PHP
// Example
$html = str_get_html(" foo bar ");
$e = $html->find("div", 0);
echo $e->tag; // Returns: " div"
echo $e->outertext; // Returns: " foo bar "
echo $e->innertext; // Returns: " foo bar"
echo $e->plaintext; // Returns: " foo bar"
```
```APIDOC
Attribute Name
$e->tag
Usage: Read or write the tag name of element.
$e->outertext
Usage: Read or write the outer HTML text of element.
$e->innertext
Usage: Read or write the inner HTML text of element.
$e->plaintext
Usage: Read or write the plain text of element.
```
--------------------------------
### PHP Simple HTML DOM Parser: Releasing Memory
Source: https://github.com/yuzdzhan/htmltodocx/blob/master/simplehtmldom/manual/manual_faq.htm
This snippet addresses memory leak issues in PHP 5 related to circular references when using the DOM parser. It demonstrates the essential steps of calling `$html->clear()` and `unset($html)` to properly free memory after processing a DOM object, especially when `file_get_dom()` is invoked multiple times.
```PHP
$html = file_get_html(...);
// do something...
$html->clear();
unset($html);
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests. |