Sha256: 50da2370608c66df1886a8371072d39c4612187dd9c1a6df5352fb47e98ea1fc

Contents?: true

Size: 447 Bytes

Versions: 4

Compression:

Stored size: 447 Bytes

Contents

require 'peddler/parsers/base'

module Peddler
  module Parsers
    class XML < Base
      def self.handle?(type)
        type == :xml
      end

      def at_xpath(path)
        document.at_xpath(with_namespace(path))
      end

      def xpath(path)
        document.xpath(with_namespace(path))
      end

      private

      def with_namespace(path)
        path.split('/').map { |attr| "xmlns:#{attr}" }.join('/')
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
peddler-0.6.3 lib/peddler/parsers/xml.rb
peddler-0.6.2 lib/peddler/parsers/xml.rb
peddler-0.6.1 lib/peddler/parsers/xml.rb
peddler-0.6.0 lib/peddler/parsers/xml.rb