這可能是一個基本的問題,但是,我有一玩就是XML格式。我想抓住揚聲器和揚聲器在字典中的行,以便將其添加到數組中。這裏是格式XML解析只有特定的子元素
<SPEECH>
<SPEAKER>Narrator</SPEAKER>
<LINE>Two households, both alike in dignity,</LINE>
<LINE>In fair Verona, where we lay our scene,</LINE>
<LINE>From ancient grudge break to new mutiny,</LINE>
<LINE>Where civil blood makes civil hands unclean.</LINE>
<LINE>From forth the fatal loins of these two foes</LINE>
<LINE>A pair of star-cross'd lovers take their life;</LINE>
<LINE>Whole misadventured piteous overthrows</LINE>
<LINE>Do with their death bury their parents' strife.</LINE>
<LINE>The fearful passage of their death-mark'd love,</LINE>
<LINE>And the continuance of their parents' rage,</LINE>
<LINE>Which, but their children's end, nought could remove,</LINE>
<LINE>Is now the two hours' traffic of our stage;</LINE>
<LINE>The which if you with patient ears attend,</LINE>
<LINE>What here shall miss, our toil shall strive to mend.</LINE>
</SPEECH>
所以我想抓住Narrator
爲揚聲器和他/她的線,並將其添加到字典中。之後,我想將字典添加到數組中,然後清除字典。
我該怎麼做?
感謝
是語言和工具集不可知的問題嗎? – Vlad
@BitT - rmaddy完全正確地刪除了Xcode標籤(因爲這不是關於Xcode IDE的問題)。但是,您應該讓我們知道這是iOS問題還是Mac OS問題。您還應該讓我們知道您是否使用NSXMLParser或其他解析器。隨意更新問題並添加適當的標籤(例如,NSXMLParser,iOS,MacOS等)。 – Rob