Created
August 7, 2012 18:30
-
-
Save sam/3288110 to your computer and use it in GitHub Desktop.
JRuby + Xerces
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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