Class MARC::XMLReader
In: lib/marc/xmlreader.rb
Parent: Object

the constructor which you can pass either a filename:

  reader = MARC::XMLReader.new('/Users/edsu/marc.xml')

or a File object,

  reader = Marc::XMLReader.new(File.new('/Users/edsu/marc.xml'))

or really any object that responds to read(n)

  reader = MARC::XMLReader.new(StringIO.new(xml))

By default, XMLReader uses REXML‘s pull parser, but you can swap that out with Nokogiri or jrexml (or let the system choose the ‘best’ one). The :parser can either be one of the defined constants or the constant‘s value.

  reader = MARC::XMLReader.new(fh, :parser=>'magic')

It is also possible to set the default parser at the class level so all subsequent instances will use it instead:

  MARC::XMLReader.best_available
  "nokogiri" # returns parser name, but doesn't set it.

Use:

  MARC::XMLReader.best_available!

or

  MARC::XMLReader.nokogiri!

Methods

Included Modules

Enumerable

Constants

USE_BEST_AVAILABLE = 'magic'
USE_REXML = 'rexml'
USE_NOKOGIRI = 'nokogiri'
USE_JREXML = 'jrexml'

Attributes

parser  [R] 

Public Class methods

Returns the value of the best available parser

Sets the best available parser as the default

Sets jrexml as the default parser

Sets Nokogiri as the default parser

Returns the currently set parser type

Sets the class parser

Returns an array of all the parsers available

Sets REXML as the default parser

Protected Class methods

[Validate]