如何解析本地XML文件以便能夠將其字符串值放入TextView.setText(String)
方法中?我的本地XML文件看起來是這樣的:解析Android中的索引XML
<quran>
<sura index="1" name="الفاتحة">
<aya index="1" text="In the name of Allah, the Entirely Merciful, the Especially Merciful."/>
<aya index="2" text="[All] praise is [due] to Allah, Lord of the worlds -"/>
<aya index="3" text="The Entirely Merciful, the Especially Merciful,"/>
<aya index="4" text="Sovereign of the Day of Recompense."/>
<aya index="5" text="It is You we worship and You we ask for help."/>
<aya index="6" text="Guide us to the straight path -"/>
<aya index="7" text="The path of those upon whom You have bestowed favor, not of those who have evoked [Your] anger or of those who are astray."/>
</sura>
<sura index="2" name="البقرة">
<aya index="1" text="Alif, Lam, Meem."/>
<aya index="2" text="This is the Book about which there is no doubt, a guidance for those conscious of Allah -"/>
<aya index="3" text="Who believe in the unseen, establish prayer, and spend out of what We have provided for them,"/>
<aya index="4" text="And who believe in what has been revealed to you, [O Muhammad], and what was revealed before you, and of the Hereafter they are certain [in faith]."/>
<aya index="5" text="Those are upon [right] guidance from their Lord, and it is those who are the successful."/>
我希望能夠訪問特定的位於特定AYH索引編號文本字符串,但我不知道如何做到這一點,因爲對中的每個對象綾一個sura對象有兩個東西,索引和我想要訪問的文本。請幫忙!
使用XML拉解析器 – 2013-05-07 11:38:31
任何想法,我如何去了解它專門爲這個文件或一個很好的教程?我需要能夠一次訪問一個字符串,有點像搜索。用戶輸入位置,並將字符串放置在TextView中。 – 2013-05-07 11:45:33
我喜歡[本教程](http://www.ibm.com/developerworks/opensource/library/x-android/)。它會遍歷所有常見的解析器並將它們全部進行比較,以便您知道哪個解決方案適合您。 – 2013-05-07 21:30:07