Skip to content

Instantly share code, notes, and snippets.

@sam
Created August 7, 2012 18:30
Show Gist options
  • Save sam/3288110 to your computer and use it in GitHub Desktop.
Save sam/3288110 to your computer and use it in GitHub Desktop.
JRuby + Xerces
# You can download the Xerces jar here:
# http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22xerces%22
require "java"
require "xerces-2.4.0-sources.jar"
url = java.net.URL.new("http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topsongs/limit=10/xml")
connection = url.open_connection
builder = javax.xml.parsers.DocumentBuilderFactory.new_instance.new_document_builder
dom = builder.parse(connection.input_stream)
attributes = dom.document_element.attributes
attributes.length.times do |i|
node = attributes.item i
puts "#{node.name}: #{node.value}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment