Class: Krikri::XmlParser
- Defined in:
- lib/krikri/parsers/xml_parser.rb
Overview
An XmlParser
Direct Known Subclasses
MARCXMLParser, ModsParser, OaiDcParser, PrimoParser, QdcParser
Defined Under Namespace
Classes: EmptyRootNodeError, Value
Instance Attribute Summary
Attributes inherited from Parser
Instance Method Summary collapse
-
#initialize(record, root_path = '/', ns = {}) ⇒ XmlParser
constructor
be parsed by the parser instance.
Methods inherited from Parser
Constructor Details
#initialize(record, root_path = '/', ns = {}) ⇒ XmlParser
be parsed by the parser instance. the desired parse root. For each hash item, the key refers to the prefix used, and its value is the associated namespace URI.
14 15 16 17 18 19 20 21 |
# File 'lib/krikri/parsers/xml_parser.rb', line 14 def initialize(record, root_path = '/', ns = {}) xml = Nokogiri::XML(record.to_s) ns = namespaces_from_xml(xml).merge(ns) root_node = xml.at_xpath(root_path, ns) raise EmptyRootNodeError if root_node.nil? @root = Value.new(root_node, ns) super(record) end |