original_string: protected static function _loadXml($input, $options)
      {
          $hasDisable = function_exists('libxml_disable_entity_loader');
          $internalErrors = libxml_use_internal_errors(true);
          if ($hasDisable && !$options['loadEntities']) {
              libxml_disable_entity_loader(true);
          }
          $flags = 0;
          if (!empty($options['parseHuge'])) {
              $flags |= LIBXML_PARSEHUGE;
          }
          try {
              if ($options['return'] === 'simplexml' || $options['return'] === 'simplexmlelement') {
                  $flags |= LIBXML_NOCDATA;
                  $xml = new SimpleXMLElement($input, $flags);
              } else {
                  $xml = new DOMDocument();
                  $xml->loadXML($input, $flags);
              }
  
              return $xml;
          } catch (Exception $e) {
              throw new XmlException('Xml cannot be read. ' . $e->getMessage(), null, $e);
          } finally {
              if ($hasDisable && !$options['loadEntities']) {
                  libxml_disable_entity_loader(false);
              }
              libxml_use_internal_errors($internalErrors);
          }
      }
code: protected static function _loadXml($input, $options)
      {
          $hasDisable = function_exists('libxml_disable_entity_loader');
          $internalErrors = libxml_use_internal_errors(true);
          if ($hasDisable && !$options['loadEntities']) {
              libxml_disable_entity_loader(true);
          }
          $flags = 0;
          if (!empty($options['parseHuge'])) {
              $flags |= LIBXML_PARSEHUGE;
          }
          try {
              if ($options['return'] === 'simplexml' || $options['return'] === 'simplexmlelement') {
                  $flags |= LIBXML_NOCDATA;
                  $xml = new SimpleXMLElement($input, $flags);
              } else {
                  $xml = new DOMDocument();
                  $xml->loadXML($input, $flags);
              }
  
              return $xml;
          } catch (Exception $e) {
              throw new XmlException('Xml cannot be read. ' . $e->getMessage(), null, $e);
          } finally {
              if ($hasDisable && !$options['loadEntities']) {
                  libxml_disable_entity_loader(false);
              }
              libxml_use_internal_errors($internalErrors);
          }
      }
code_tokens: protected static function _loadXml ( $ input , $ options ) { $ hasDisable = function_exists ( 'libxml_disable_entity_loader' ) ; $ internalErrors = libxml_use_internal_errors ( true ) ; if ( $ hasDisable && ! $ options [ 'loadEntities' ] ) { libxml_disable_entity_loader ( true ) ; } $ flags = 0 ; if ( ! empty ( $ options [ 'parseHuge' ] ) ) { $ flags |= LIBXML_PARSEHUGE ; } try { if ( $ options [ 'return' ] === 'simplexml' || $ options [ 'return' ] === 'simplexmlelement' ) { $ flags |= LIBXML_NOCDATA ; $ xml = new SimpleXMLElement ( $ input , $ flags ) ; } else { $ xml = new DOMDocument ( ) ; $ xml -> loadXML ( $ input , $ flags ) ; } return $ xml ; } catch ( Exception $ e ) { throw new XmlException ( 'Xml cannot be read. ' . $ e -> getMessage ( ) , null , $ e ) ; } finally { if ( $ hasDisable && ! $ options [ 'loadEntities' ] ) { libxml_disable_entity_loader ( false ) ; } libxml_use_internal_errors ( $ internalErrors ) ; } }
docstring: Parse the input data and create either a SimpleXmlElement object or a DOMDocument.
  
  @param string $input The input to load.
  @param array $options The options to use. See Xml::build()
  @return \SimpleXMLElement|\DOMDocument
  @throws \Cake\Utility\Exception\XmlException
docstring_tokens: Parse the input data and create either a SimpleXmlElement object or a DOMDocument .