public function QueryPath::textBefore in QueryPath 7.3
Same name and namespace in other branches
- 6 QueryPath/QueryPath.php \QueryPath::textBefore()
- 7.2 QueryPath/QueryPath.php \QueryPath::textBefore()
File
- QueryPath/
QueryPath.php, line 1264
Class
Code
public function textBefore($text = NULL) {
if (isset($text)) {
$textNode = $this->document
->createTextNode($text);
return $this
->before($textNode);
}
$buffer = '';
foreach ($this->matches as $m) {
$p = $m;
while (isset($p->previousSibling) && $p->previousSibling->nodeType == XML_TEXT_NODE) {
$p = $p->previousSibling;
$buffer .= $p->textContent;
}
}
return $buffer;
}