0
我有一些xml在服務器上(http://server.com/my.xml)。這裏是例子:Ruby(RoR)XML哈希,然後顯示在視圖
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE current PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<current>
<song>Bruce - Inside The Machine</song>
<song>02 Duel of the Fates 1</song>
</current>
on Rails應用程序我做的:
response = open("http://server.com/my.xml").read
@sngs = Hash.from_xml(response)
現在,在視圖中,我希望把每一個「歌」的值在例如「P」的標籤,但不一個接一個。我必須把例如確切的第一或第二。
怎麼可以做到?
(很多,非常感謝!)
謝謝!這正是我需要的!謝謝格雷格! – 2009-11-05 23:02:40