36 if (! $this->localName) {
40 return '{' . $this->namespaceURI .
'}' . $this->localName;
59 $previousEntityState = libxml_disable_entity_loader(
true);
60 $previousSetting = libxml_use_internal_errors(
true);
68 while ($this->nodeType !== self::ELEMENT && @$this->read()) {
74 libxml_clear_errors();
80 libxml_use_internal_errors($previousSetting);
81 libxml_disable_entity_loader($previousEntityState);
134 if ($this->nodeType === self::ELEMENT && $this->isEmptyElement) {
140 if (!is_null($elementMap)) {
142 $this->elementMap = $elementMap;
151 if (!@$this->read()) {
153 libxml_clear_errors();
157 throw new ParseException(
'This should never happen (famous last words)');
162 if (!$this->isValid()) {
167 libxml_clear_errors();
172 switch ($this->nodeType) {
178 $text .= $this->value;
181 case self::END_ELEMENT :
186 throw new ParseException(
'We hit the end of the document prematurely. This likely means that some parser "eats" too many elements. Do not attempt to continue parsing.');
197 if (!is_null($elementMap)) {
202 return ($elements ? $elements :
$text);
214 $previousDepth = $this->depth;
216 while ($this->read() && $this->depth != $previousDepth) {
217 if (in_array($this->nodeType, [XMLReader::TEXT, XMLReader::CDATA, XMLReader::WHITESPACE])) {
241 if ($this->hasAttributes) {
245 $value = call_user_func(
272 while ($this->moveToNextAttribute()) {
273 if ($this->namespaceURI) {
276 if ($this->namespaceURI ===
'http://www.w3.org/2000/xmlns/') {
287 $this->moveToElement();
303 if (!array_key_exists(
$name, $this->elementMap)) {
304 if (substr(
$name, 0, 2) ==
'{}' && array_key_exists(substr(
$name, 2), $this->elementMap)) {
307 return [
'Sabre\\Xml\\Element\\Base',
'xmlDeserialize'];
311 $deserializer = $this->elementMap[
$name];
312 if (is_subclass_of($deserializer,
'Sabre\\Xml\\XmlDeserializable')) {
313 return [$deserializer,
'xmlDeserialize'];
316 if (is_callable($deserializer)) {
317 return $deserializer;
320 $type = gettype($deserializer);
321 if (
$type ===
'string') {
322 $type .=
' (' . $deserializer .
')';
323 } elseif (
$type ===
'object') {
324 $type .=
' (' . get_class($deserializer) .
')';
326 throw new \LogicException(
'Could not use this type as a deserializer: ' .
$type .
' for element: ' .
$name);
parseInnerTree(array $elementMap=null)
Parses all elements below the current element.
getDeserializerForElementName($name)
Returns the function that should be used to parse the element identified by it's clark-notation name...
parseAttributes()
Grabs all the attributes from the current element, and returns them as a key-value array...
parse()
Reads the entire document.
This is a base exception for any exception related to parsing xml files.
trait ContextStackTrait
Context Stack.
popContext()
Restore the previous "context".
parseGetElements(array $elementMap=null)
parseGetElements parses everything in the current sub-tree, and returns a an array of elements...
parseCurrentElement()
Parses the current XML element.
This exception is thrown when the Readers runs into a parsing error.
The Reader class expands upon PHP's built-in XMLReader.
pushContext()
Create a new "context".
if(array_key_exists('yes', $_REQUEST)) $attributes
readText()
Reads all text below the current element, and returns this as a string.
getClark()
Returns the current nodename in clark-notation.