Class: Krikri::XmlParser

Inherits:
Parser
  • Object
show all
Defined in:
lib/krikri/parsers/xml_parser.rb

Overview

An XmlParser

See Also:

Direct Known Subclasses

ModsParser, OaiDcParser, QdcParser

Defined Under Namespace

Classes: Value

Instance Attribute Summary

Attributes inherited from Parser

#record, #root

Instance Method Summary collapse

Methods inherited from Parser

parse

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
# 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 = Value.new(xml.at_xpath(root_path, ns), ns)
  super(record)
end