lib/rixml.rb in rixml-0.1.2 vs lib/rixml.rb in rixml-0.1.3

- old
+ new

@@ -4,21 +4,19 @@ require 'active_support/core_ext/hash/conversions' require 'active_support/inflector/inflections' class RIXML class << self - def parse(data) - RIXML.new(Nokogiri::XML(data).root) - end - def parse_from_file(filename) - parse File.read(filename) + RIXML.new(File.read(filename)) end end - def initialize(document) - @attrs = Hash.from_xml(document.to_s) + def initialize(data) + @document = Nokogiri::XML(data) + @attrs = Hash.from_xml(@document.root.to_s) + @document.remove_namespaces! end def product_id @attrs.dig('Research', 'Product', 'productID') end @@ -59,9 +57,13 @@ { companies: parse_companies_from_context(context), sectors: parse_sectors_from_context(context), countries: parse_countries_from_context(context) } + end + + def xpath(path) + @document.xpath(path) end private def parse_info_from_author(author)