私のxmlは次のようになります。
<entry>
<updated>2012-11-14T13:58:49-07:00</updated>
<id im:id="557137623" im:bundleId="com.rovio.angrybirdsstarwars">Some text</id>
<title>Angry Birds Star Wars - Rovio Entertainment Ltd</title>
</entry>
<entry>
<updated>2012-11-14T13:58:49-07:00</updated>
<id im:id="557137623" im:bundleId="com.rovio.angrybirdsstarwars">Some text</id>
<title>Angry Birds Star Wars - Rovio Entertainment Ltd</title>
</entry>
Nokogiri を使用して xml からデータを取得したいと思います。つまり、上記の xml のim:id
とim:bundleId
に興味があります。<title>
これが機能する段階に到達することができました:
xml.css("entry id").each do |entry|
puts entry["im:id"]
puts entry["im:bundleid"]
end
問題は、コンテンツを取得するには、個別title
に反復処理する必要があることです。エントリを繰り返し処理してから、データをxml.css("entry title")
引き出して同じループに入れる方法はありますか?id
title