// Really sorry about the silence operator, seems like I have no
// choice. See:
//
// https://bugs.php.net/bug.php?id=64230
if(!@$this->read())returnfalse;
while(true){
if(!$this->isValid()){
$errors=libxml_get_errors();
if($errors){
libxml_clear_errors();
thrownewLibXMLException($errors);
}
}
switch($this->nodeType){
caseself::ELEMENT:
$elements[]=$this->parseCurrentElement();
break;
caseself::TEXT:
caseself::CDATA:
$text.=$this->value;
$this->read();
break;
caseself::END_ELEMENT:
// Ensuring we are moving the cursor after the end element.
$this->read();
break2;
caseself::NONE:
thrownewParseException('We hit the end of the document prematurely. This likely means that some parser "eats" too many elements. Do not attempt to continue parsing.');
default:
// Advance to the next element
$this->read();
break;
}
}
if(!is_null($elementMap)){
$this->popContext();
}
return($elements?$elements:$text);
}
/**
* Reads all text below the current element, and returns this as a string.