Sha256: e2b03eb2b80f3dfc039b96abe33a0fb0af421fa342814e12d2ea62cd2618e25f
Contents?: true
Size: 989 Bytes
Versions: 3
Compression:
Stored size: 989 Bytes
Contents
#!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../spec/spec_helper') # The document `pita.xml` contains both a default namespace and the 'georss' # namespace (for the 'point' xml_reader). module PITA class Base include ROXML xml_convention :camelcase end class Item < Base xml_reader :asin, :from => 'ASIN' xml_reader :detail_page_url, :from => 'DetailPageURL' xml_reader :manufacturer, :in => './' # this is the only xml_reader that exists in a different namespace, so it # must be explicitly specified xml_reader :point, :from => 'georss:point' end class ItemSearchResponse < Base xml_reader :total_results, :as => Integer, :in => 'Items' xml_reader :total_pages, :as => Integer, :in => 'Items' xml_reader :items, [Item] end end unless defined?(Spec) item = PITA::ItemSearchResponse.from_xml(xml_for('amazon')) item.items.each do |i| puts i.asin, i.detail_page_url, i.manufacturer, '' end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
Empact-roxml-2.4.3 | examples/amazon.rb |
roxml-2.4.3 | examples/amazon.rb |
roxml-2.4.2 | examples/amazon.rb |