original_string: public function parse($data, $whitespace = 1, $encoding = 'UTF-8', $reporterrors = false) {
          $data = trim($data);
          $this->xml = array();
          $this->current = array();
          $this->level = 0;
          $this->current[0] = & $this->xml;
          $parser = xml_parser_create($encoding);
          xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
          xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, $whitespace);
          xml_set_element_handler($parser, [$this, "startelement"], [$this, "endelement"]);
          xml_set_character_data_handler($parser, [$this, "characterdata"]);
          // Start parsing an xml document.
          for ($i = 0; $i < strlen($data); $i += 4096) {
              if (!xml_parse($parser, substr($data, $i, 4096))) {
                  break;
              }
          }
          if ($reporterrors) {
              $errorcode = xml_get_error_code($parser);
              if ($errorcode) {
                  $exception = new xml_format_exception(xml_error_string($errorcode),
                          xml_get_current_line_number($parser),
                          xml_get_current_column_number($parser));
                  xml_parser_free($parser);
                  throw $exception;
              }
          }
          xml_parser_free($parser); // Deletes the parser.
          if (empty($this->xml)) { // XML file is invalid or empty, return false.
              return false;
          }
          return $this->xml;
      }
code: public function parse($data, $whitespace = 1, $encoding = 'UTF-8', $reporterrors = false) {
          $data = trim($data);
          $this->xml = array();
          $this->current = array();
          $this->level = 0;
          $this->current[0] = & $this->xml;
          $parser = xml_parser_create($encoding);
          xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
          xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, $whitespace);
          xml_set_element_handler($parser, [$this, "startelement"], [$this, "endelement"]);
          xml_set_character_data_handler($parser, [$this, "characterdata"]);
          // Start parsing an xml document.
          for ($i = 0; $i < strlen($data); $i += 4096) {
              if (!xml_parse($parser, substr($data, $i, 4096))) {
                  break;
              }
          }
          if ($reporterrors) {
              $errorcode = xml_get_error_code($parser);
              if ($errorcode) {
                  $exception = new xml_format_exception(xml_error_string($errorcode),
                          xml_get_current_line_number($parser),
                          xml_get_current_column_number($parser));
                  xml_parser_free($parser);
                  throw $exception;
              }
          }
          xml_parser_free($parser); // Deletes the parser.
          if (empty($this->xml)) { // XML file is invalid or empty, return false.
              return false;
          }
          return $this->xml;
      }
code_tokens: public function parse ( $ data , $ whitespace = 1 , $ encoding = 'UTF-8' , $ reporterrors = false ) { $ data = trim ( $ data ) ; $ this -> xml = array ( ) ; $ this -> current = array ( ) ; $ this -> level = 0 ; $ this -> current [ 0 ] = & $ this -> xml ; $ parser = xml_parser_create ( $ encoding ) ; xml_parser_set_option ( $ parser , XML_OPTION_CASE_FOLDING , 0 ) ; xml_parser_set_option ( $ parser , XML_OPTION_SKIP_WHITE , $ whitespace ) ; xml_set_element_handler ( $ parser , [ $ this , "startelement" ] , [ $ this , "endelement" ] ) ; xml_set_character_data_handler ( $ parser , [ $ this , "characterdata" ] ) ; // Start parsing an xml document. for ( $ i = 0 ; $ i < strlen ( $ data ) ; $ i += 4096 ) { if ( ! xml_parse ( $ parser , substr ( $ data , $ i , 4096 ) ) ) { break ; } } if ( $ reporterrors ) { $ errorcode = xml_get_error_code ( $ parser ) ; if ( $ errorcode ) { $ exception = new xml_format_exception ( xml_error_string ( $ errorcode ) , xml_get_current_line_number ( $ parser ) , xml_get_current_column_number ( $ parser ) ) ; xml_parser_free ( $ parser ) ; throw $ exception ; } } xml_parser_free ( $ parser ) ; // Deletes the parser. if ( empty ( $ this -> xml ) ) { // XML file is invalid or empty, return false. return false ; } return $ this -> xml ; }
docstring: Parses XML string.
  
  Note: Interface is kept equal to previous version.
  
  @author Kilian Singer
  @param string $data the XML source to parse.
  @param int $whitespace If set to 1 allows the parser to skip "space" characters in xml document. Default is 1
  @param string $encoding Specify an OUTPUT encoding. If not specified, it defaults to UTF-8.
  @param bool $reporterrors if set to true, then a {@link xml_format_exception}
  exception will be thrown if the XML is not well-formed. Otherwise errors are ignored.
  @return array representation of the parsed XML.
docstring_tokens: Parses XML string .