Analyse XML avec Nokogiri

Avoir quelques problèmes à obtenir la bonne configuration pour Nokogiri et leur documentation est un peu rude pour commencer avec.

Je suis en train d'analyser le fichier XML: http://www.kongregate.com/games_for_your_site.xml

Qui renvoie à plusieurs jeux à l'intérieur de la gameset, et pour chaque jeu, il a un titre, la description, etc....

<gameset>
<game>
<id>160342</id>
<title>Tricky Rick</title>
<thumbnail>
http://cdn3.kongregate.com/game_icons/0042/7180/KONG_icon250x200_site.png?21656-op
</thumbnail>
<launch_date>2012-12-12</launch_date>
<category>Puzzle</category>
<flash_file>
http://external.kongregate-games.com/gamez/0016/0342/live/embeddable_160342.swf
</flash_file>
<width>640</width>
<height>480</height>
<url>
http://www.kongregate.com/games/tAMAS_Games/tricky-rick
</url>
<description>
Help Rick to collect all the stolen fuel to refuel his spaceship and fly away from the planet. Use hammer, bombs, jetpack and other useful stuff to solve puzzles!
</description>
<instructions>
WASD \ Arrow Keys &#8211; move; S \ Down Arrow &#8211; take\release an object; CNTRL &#8211; interaction with objects: throw, hammer strike, invisibility mode; SPACE &#8211; interaction with elevators and fuel stations; Esc \ P &#8211; pause;
</instructions>
<developer_name>tAMAS_Games</developer_name>
<gameplays>24999</gameplays>
<rating>3.43</rating>
</game>
<game>
<id>160758</id>
<title>Flying Cookie Quest</title>
<thumbnail>
http://cdn2.kongregate.com/game_icons/0042/8428/icon_cookiequest_kong_250x200_site.png?16578-op
</thumbnail>
<launch_date>2012-12-07</launch_date>
<category>Action</category>
<flash_file>
http://external.kongregate-games.com/gamez/0016/0758/live/embeddable_160758.swf
</flash_file>
<width>640</width>
<height>480</height>
<url>
http://www.kongregate.com/games/LongAnimals/flying-cookie-quest
</url>
<description>
Launch Rocket Panda into the land of Cookies. With the help of low-flying sharks, hang-gliding sheep and Rocket Badger, can you defeat the all powerful Biscuit Head? Defeat All enemies of cookies in this launcher game.
</description>
<instructions>Use the mouse button!</instructions>
<developer_name>LongAnimals</developer_name>
<gameplays>168672</gameplays>
<rating>3.67</rating>
</game>

De la documentation, je suis en utilisant quelque chose comme:

require 'nokogiri'
require 'open-uri'
url = "http://www.kongregate.com/games_for_your_site.xml"
xml = Nokogiri::XML(open(url))
xml.xpath("//game").each do |node|
puts node.xpath("//id")
puts node.xpath("//title")
puts node.xpath("//thumbnail")
puts node.xpath("//category")
puts node.xpath("//flash_file")
puts node.xpath("//width")
puts node.xpath("//height")
puts node.xpath("//description")
puts node.xpath("//instructions")
end

Mais, elle retourne sans fin de données, et non pas dans un ensemble. Toute aide serait utile.

De quelle manière avez-vous trouver le Nokogiri documents "bruts"? Sont les tutoriels nokogiri.org en manque de quelque chose? Est le rdoc documentation manque quelque chose qui vous aurait aidé ici?
Il a vraiment à faire avec ce que l'homme de fer-blanc des etats-dessous

OriginalL'auteur thebusiness11 | 2013-01-01