2012-07-01 32 views
0

我正在從事聖經每日一節的工作,我希望它是隨機的。我有經文的XML,看起來像這樣:在iPhone的TextView中顯示XML中的隨機元素

<bible translation="KJV"> 
<testament name="Old"> 

    <book name="Genesis"> 
     <chapter number="1"> 
      <verse number="1">In the beginning God created the heaven and the earth.</verse> 
      <verse number="2">And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters. </verse> 

<!-- THE REST OF THE XML HERE --> 

        </chapter> 
      </book> 
    </testament> 

我想用一個解析器來從詩句中的一個創造文字的NSString,但他們都被列爲有可能成爲這些元素中的幾個元素,並且名稱各不相同。有關我如何做到這一點的任何建議?

回答

0

您可以使用plist而不是XML實現。我發現plists易於實施和管理。

你可以將你的plist加載到字典中,然後從那裏隨機選擇。

+0

有沒有簡單的方法將xml轉換爲plist?這是唯一要麼找到聖經的plist,要麼是一個簡單的方法來轉換一個 – user717452

+0

plist的格式與XML相似。查看plist的文本格式,你會看到它不會太糟糕。 –