read a XML file
 opts::
 * :file - The filename of the file to load
 * :data - The data to parse
965007
def load(opts)
      @doc = nil

      if(opts.has_key?(:file)) then
        File.open(opts[:file], :external_encoding => "ASCII") do |fd|
          @doc = StringScanner.new(fd.read)
        end
      else
        @doc = StringScanner.new(opts[:data])
      end

      if @doc
        root = import_plain
        raise CFFormatError.new('content after root object') unless @doc.eos?

        return root
      end

      raise CFFormatError.new('invalid plist string or file not found')
    end
1332957
def parse_file(self, file_or_fname):
        
        with self._context():
            if hasattr(file_or_fname, 'read'):
                self.filename = getattr(
                    file_or_fname, 'name', file_or_fname.__class__.__name__)
                self.p.ParseFile(file_or_fname)
            else:
                self.filename = file_or_fname
                with open(file_or_fname, 'rb') as f:
                    self.p.ParseFile(f)
        return self._root
179734
def _read_file_data(self, path):
        
        _, ext = os.path.splitext(path)
        # YAML files
        if ext in ('.yml', '.yaml'):
            try:
                with open(path) as f:
                    return yaml.safe_load(f)
            except YAMLError as e:
                raise ConfigParseError(path, e)
        # JSON files
        elif ext == '.json':
            try:
                return json.loads(open(path).read())
            except ValueError as e:
                raise ConfigParseError(path, e)
        else:
            raise ConfigParseError(path, TypeError("Unsupported file type {}".format(ext)))
1248420
def parse( file )
      pattern = PATTERNS[ File.extname( file ) ]

      IO.readlines( file ).take_while do |line|
        line =~ pattern
      end.map { |line| line[ pattern, 1 ] }
    end
264021
def parse(data)
      if !data.respond_to?(:read)
        data = StringIO.new(data || "")
      end

      if data.eof?
        {}
      else
        doc = Nokogiri::XML(data)
        raise doc.errors.first if doc.errors.length > 0
        doc.to_hash
      end
    end
223824
def parse(contents, name, ext)
      hash = case ext
        when *YML_FILE_TYPES
          YAML::load(contents)
        when *XML_FILE_TYPES
          parse_xml(contents, name)
        when *CNF_FILE_TYPES
          RConfig::PropertiesFile.parse(contents)
        else
          raise ConfigError, "Unknown File type: #{ext}"
        end
      hash.freeze
    end
944623
def main_from_xml(file)
      xml_data = File.read(file)
      xml_data.force_encoding('utf-8')

      doc = Nokogiri::XML(xml_data)
      doc.elements.first.elements.first
    end
98674
def read_data_file(path)
      case File.extname(path).downcase
      when ".csv"
        CSV.read(path,
                 :headers  => true,
                 :encoding => site.config["encoding"]).map(&:to_hash)
      when ".tsv"
        CSV.read(path,
                 :col_sep  => "\t",
                 :headers  => true,
                 :encoding => site.config["encoding"]).map(&:to_hash)
      else
        SafeYAML.load_file(path)
      end
    end
916646
def read_file(self):
        
        with open(self.filename, mode='r+', encoding='utf8') as text_file:
            self.raw_file = text_file.read()  # pylint: disable= attribute-defined-outside-init
        self.file_lines = [x.rstrip() for x in self.raw_file.splitlines()]
290923
def read_file(path)
      data = nil
      File.open(path, "r") do |file|
        file.flock(File::LOCK_EX)
        data = file.read
        file.flock(File::LOCK_UN)
      end

      data
    end
941301
def parse
      return nil unless File.file?(@file)

      doc = parse_xml(@file)
      doc.xpath('w:comments/*').each do |node_child|
        case node_child.name
        when 'comment'
          @comments_array << Comment.new(parent: self).parse(node_child)
        end
      end
      self
    end
1120839
def parse_from_file(filename, nodata=False):
    
    header = None
    with open(filename, "rb") as file:
        header = read_machine_header(file)
        meta_raw = file.read(header['meta_len'])
        meta = __parse_meta(meta_raw, header)
        data = b''
        if not nodata:
            data = __decompress(meta, file.read(header['data_len']))

        return header, meta, data
900483
def read(opts = {})
      Jekyll.logger.debug "Reading:", relative_path

      if yaml_file?
        @data = SafeYAML.load_file(path)
      else
        begin
          merge_defaults
          read_content(opts)
          read_post_data
        rescue StandardError => e
          handle_read_error(e)
        end
      end
    end
1211599
def readerForFile(filename, encoding, options):
    
    ret = libxml2mod.xmlReaderForFile(filename, encoding, options)
    if ret is None:raise treeError('xmlReaderForFile() failed')
    return xmlTextReader(_obj=ret)
804135
def read(opts = {})
      Bunto.logger.debug "Reading:", relative_path

      if yaml_file?
        @data = SafeYAML.load_file(path)
      else
        begin
          merge_defaults
          read_content(opts)
          read_post_data
        rescue SyntaxError => e
          Bunto.logger.error "Error:", "YAML Exception reading #{path}: #{e.message}"
        rescue => e
          raise e if e.is_a? Bunto::Errors::FatalException
          Bunto.logger.error "Error:", "could not read file #{path}: #{e.message}"
        end
      end
    end
853109
function readData(fp, options) {
  // shallow clone options
  var opts = utils.extend({}, options);
  // get the loader for this file.
  var ext = opts.lang || path.extname(fp);
  if (ext && ext.charAt(0) !== '.') {
    ext = '.' + ext;
  }
  if (!this.dataLoaders.hasOwnProperty(ext)) {
    return this.dataLoader('read')(fp, opts);
  }
  return this.dataLoader(ext)(fp, opts);
}
423456
def readFile(filename, encoding, options):
    
    ret = libxml2mod.xmlReadFile(filename, encoding, options)
    if ret is None:raise treeError('xmlReadFile() failed')
    return xmlDoc(_obj=ret)