You are here

function ARC_rdfxml_parser::parse_file in Taxonomy import/export via XML 5

Same name and namespace in other branches
  1. 5.2 arc/ARC_rdfxml_parser.php \ARC_rdfxml_parser::parse_file()
  2. 6.2 arc/ARC_rdfxml_parser.php \ARC_rdfxml_parser::parse_file()
  3. 6 arc/ARC_rdfxml_parser.php \ARC_rdfxml_parser::parse_file()

File

arc/ARC_rdfxml_parser.php, line 960

Class

ARC_rdfxml_parser

Code

function parse_file($path) {
  if ($fp = fopen($path, "r")) {
    if (!$this->init_args["base"]) {
      $this->init_args["base"] = $path;
    }
    $this
      ->init(false);
    $this->encoding = $this->encoding == "auto" ? "UTF-8" : $this->encoding;
    $this
      ->create_parser();
    while ($data = fread($fp, 4096)) {
      if ($this->save_data) {
        $this->data .= $data;
      }
      if (!($success = xml_parse($this->parser, $data, feof($fp)))) {
        $error_str = xml_error_string(xml_get_error_code($this->parser));
        $line = xml_get_current_line_number($this->parser);
        fclose($fp);
        xml_parser_free($this->parser);
        return "XML error: '" . $error_str . "' at line " . $line . "\n";
      }
    }
    $this->target_encoding = xml_parser_get_option($this->parser, XML_OPTION_TARGET_ENCODING);
    xml_parser_free($this->parser);
    fclose($fp);
    $this
      ->done();
  }
  return $this->triples;
}