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!
USE_BEST_AVAILABLE | = | 'magic' |
USE_REXML | = | 'rexml' |
USE_NOKOGIRI | = | 'nokogiri' |
USE_JREXML | = | 'jrexml' |
USE_JSTAX | = | 'jstax' |
USE_LIBXML | = | 'libxml' |
parser | [R] |