Sha256: 9f19033683d177f015a09461e494bea98ed26f8353234462194e47a0d2f00b13

Contents?: true

Size: 521 Bytes

Versions: 8

Compression:

Stored size: 521 Bytes

Contents

require 'nokogiri'
require 'nori'
require 'rexml/document'

module Barometer
  module Utils
    module XmlReader
      def self.parse(xml, *nodes_to_remove)
        xml_reader = Nori.new(
          parser: :nokogiri,
          strip_namespaces: true
        )
        output = xml_reader.parse(xml)

        nodes_to_remove.each do |node|
          output = output.fetch(node, output)
        end

        if block_given? && output
          output = yield(output)
        end

        output
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
barometer-0.9.7 lib/barometer/utils/xml_reader.rb
barometer-0.9.6 lib/barometer/utils/xml_reader.rb
barometer-0.9.5 lib/barometer/utils/xml_reader.rb
barometer-0.9.4 lib/barometer/utils/xml_reader.rb
barometer-0.9.3 lib/barometer/utils/xml_reader.rb
barometer-0.9.2 lib/barometer/utils/xml_reader.rb
barometer-0.9.1 lib/barometer/utils/xml_reader.rb
barometer-0.9.0 lib/barometer/utils/xml_reader.rb