![]() |
Antidot PHP API
version 0.16.0
##PHP API to simplify integration of Antidot components
|
Helpers for DOM elements. More...
Static Public Member Functions | |
static | get_text (DOMNode $node, array $callbacks=array()) |
Retrieve text from children text nodes. |
Helpers for DOM elements.
|
static |
Retrieve text from children text nodes.
$node | [in] base node from which XML text nodes are looked for. |
$callbacks | [in] array of callbacks (default: empty array). Array keys should correspond to XML node types, array values are callbacks to be called for specific node names. These callbacks should accept a DOMNode as first parameter. |
<root> <child_1>some content</child_1> <child_2>other content</child_2> </root>Let's suppose node variable points to DOMElement child_1. You can extract text content of child_1 node by calling:
<root> <child_1>some content</child_1> <child_2>other <match>specific</match> content</child_2> </root>Let's suppor node variable points to DOMElement child_2. You can extract text content of child_2 node and its child match by calling:
If you want some formatting you can define you own FilterNode class or use provided one:
If you want different filters, each for different node name, you can provide array of filter instead of just one filter. For example: