在iPhone的TextView中显示XML中的随机元素
我正在写一篇圣经中的每日诗篇,我希望它是随机的。我有一个xml的诗句,看起来像这样:在iPhone的TextView中显示XML中的随机元素,iphone,xml,xcode,sdk,xml-parsing,Iphone,Xml,Xcode,Sdk,Xml Parsing,我正在写一篇圣经中的每日诗篇,我希望它是随机的。我有一个xml的诗句,看起来像这样: <bible translation="KJV"> <testament name="Old"> <book name="Genesis"> <chapter number="1"> <verse number="1">In the beginning God created the heaven an
<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>
起初,上帝创造了天地。
地球是没有形状的,空虚的;黑暗笼罩着深渊的表面。神的灵在水面上移动。
我想使用解析器从其中一首诗中创建一个文本字符串,但由于它们都被列出了,因此每个元素可能都有几个元素,并且它们的名称都不同。有什么建议吗?您可以使用plist而不是XML实现。我发现plists易于实现和管理
您可以将plist加载到字典中,然后从中随机选择。有没有简单的方法将xml转换为plist?这是唯一的事情,要么找到圣经的plist,要么找到一种转换plist的简单方法plist的格式非常类似于XML。查看plist的文本格式,您将看到它不会太糟糕。