You are here

protected function Kint_Parsers_Xml::_parse in Devel 8.2

Same name and namespace in other branches
  1. 8 kint/kint/parsers/custom/xml.php \Kint_Parsers_Xml::_parse()

* main and usually single method a custom parser must implement * *

Parameters

mixed $variable: * * @return mixed [!!!] false is returned if the variable is not of current type

Overrides kintParser::_parse

File

kint/kint/parsers/custom/xml.php, line 5

Class

Kint_Parsers_Xml

Code

protected function _parse(&$variable) {
  try {
    if (is_string($variable) && substr($variable, 0, 5) === '<?xml') {
      $e = libxml_use_internal_errors(true);
      $xml = simplexml_load_string($variable);
      libxml_use_internal_errors($e);
      if (empty($xml)) {
        return false;
      }
    }
    else {
      return false;
    }
  } catch (Exception $e) {
    return false;
  }
  $this->value = kintParser::factory($xml)->extendedValue;
  $this->type = 'XML';
}