Skip to content

Instantly share code, notes, and snippets.

Created November 1, 2011 23:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/1332249 to your computer and use it in GitHub Desktop.
Save anonymous/1332249 to your computer and use it in GitHub Desktop.
require 'nokogiri'
doc = Nokogiri::XML(File.open("deploy/data/BundleData.xml")) do |config| config.noblanks end
puts "Default Price:"
doc.xpath("//DefaultPrice/Choice").each { |p| puts "id: #{p['id']} price: #{p.content}" }
puts "ExistingCustPrice Price:"
doc.xpath("//ExistingCustPrice/Choice").each { |p| puts "id: #{p['id']} price: #{p.content}" }
puts "Bundled Price:"
doc.xpath("//BundledPrice/Choice").each { |p| puts "id: #{p['id']} price: #{p.content}" }
puts "Bundle Groups"
doc.xpath("//Bundle").each { |b|
if b.xpath('cod')[0]
puts "id: #{b['id']} cod: #{b.xpath('cod')[0].content} installFee: #{b.xpath('installFee')[0].content}"
else
puts "id: #{b['id']}"
end
}
puts "Bundles"
doc.xpath("//Bundle/Customization/Choice").each { |b| puts "id: #{b['id']} num_products: #{b.xpath('Choices/Choice').length}"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment