你好,我正在使用LibXML來解析一個rss提要,我想知道是否有可能使用點語法訪問內容(或者一樣簡單)。是否可以使用點語法訪問xml對象的內容?
所以,如果我有:
<post>
<created_at>Sat Aug 09 05:38:12 +0000 2008</created_at>
<id>882281424</id>
<text>I so just thought the guy lighting the Olympic torch was falling when he began to run on the wall. Wow that would have been catastrophic.</text>
<source>web</source>
<truncated>false</truncated>
<in_reply_to_status_id></in_reply_to_status_id>
<in_reply_to_user_id></in_reply_to_user_id>
</post>
我能訪問它像
text = post.text
測試這和它工作正常(與固定錯字)。如果XML僅包含' ... ',則不需要遍歷它,只要執行`puts posts.text` –
dbr
2009-07-30 07:50:13