Sha256: 5855bd91b382293f444ff9ee404ae15160af0d3105a3f0c9731d6a2f150d83fb

Contents?: true

Size: 524 Bytes

Versions: 2

Compression:

Stored size: 524 Bytes

Contents

require 'peddler/parsers/base'

module Peddler
  module Parsers
    class XML < Base
      def self.xml?
        true
      end

      def text_at_xpath(path)
        node = at_xpath(path)
        node.text if node
      end

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

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

      private

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
peddler-0.6.5 lib/peddler/parsers/xml.rb
peddler-0.6.4 lib/peddler/parsers/xml.rb