summaryrefslogtreecommitdiff
path: root/src/Readability.php
diff options
context:
space:
mode:
authorAndres Rey <[email protected]>2016-12-11 12:21:45 +0000
committerAndres Rey <[email protected]>2016-12-11 12:21:45 +0000
commit7acb69c7f6391fa2121466cd4d013727dac64e36 (patch)
tree6cb7d0671807eeb584db10256f97feadeffd037e /src/Readability.php
parent3f80edf8a2ff66be411815e12ceeb1d4ea584d46 (diff)
Added option to filter empty DOMText nodes while getting children.
Diffstat (limited to 'src/Readability.php')
-rw-r--r--src/Readability.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/Readability.php b/src/Readability.php
index e3122dd..9255bc6 100644
--- a/src/Readability.php
+++ b/src/Readability.php
@@ -476,4 +476,23 @@ class Readability extends Element implements ReadabilityInterface
}
return false;
}
+
+ /**
+ * @param bool $filterEmptyDOMText Filter empty DOMText nodes?
+ * @return array
+ */
+ public function getChildren($filterEmptyDOMText = false)
+ {
+ $ret = array();
+ /** @var \DOMNode $node */
+ foreach ($this->node->childNodes as $node) {
+ if ($filterEmptyDOMText && $node->nodeName === '#text' && !trim($node->nodeValue)) {
+ continue;
+ }
+
+ $ret[] = new static($node);
+ }
+
+ return $ret;
+ }
}