我一直在搜索最近幾天找到一種方法來設置NSXMLParser。該XML文件我需要解析如下:安裝NSXMLParser來解析本地XML文件
<matrix>
<row>eraser*met</row>
<row>debone*anat</row>
<row>ani*jalisco</row>
<row>madwoman*on</row>
<row>**joy*itsme</row>
<row>isao***amad</row>
<row>mends*mio**</row>
<row>be*parental</row>
<row>insipid*hai</row>
<row>bail*modern</row>
<row>esse*scored</row>
</matrix>
我已經實現了的NSXMLParser委託方法:
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
但我無法弄清楚如何真正通過「矩陣」步驟並將這些行保存在一個數組中。
我希望你能幫助我。
問候 塞巴斯蒂安
編輯:
這裏是整個XML文件:
<?xml version="1.0" encoding="UTF-8"?>
<grid version="1">
<matrix>
<row>eraser*met*</row>
<row>debone*anat</row>
<row>ani*jalisco</row>
<row>madwoman*on</row>
<row>**joy*itsme</row>
<row>isao***amad</row>
<row>mends*mio**</row>
<row>be*parental</row>
<row>insipid*hai</row>
<row>bail*modern</row>
<row>esse*scored</row>
</matrix>
<clues>
<across>
<clue>Rubber</clue>
<clue>Intro to physics?</clue>
<clue>Fish prep?</clue>
<clue>Med school subj.</clue>
<clue>Tropical cuckoo bird</clue>
<clue>State in W Mexico</clue>
<clue>Insane female</clue>
<clue>Not off</clue>
<clue>Happiness</clue>
<clue>"Who's there?" response</clue>
<clue>Golfer Aoki</clue>
<clue>Diary of ___ Housewife</clue>
<clue>Fixes</clue>
<clue>O Sole ___</clue>
<clue>To exist</clue>
<clue>Maternal or paternal</clue>
<clue>Vapid</clue>
<clue>Yes, in Yokohama</clue>
<clue>Remove water from a boat</clue>
<clue>Contemporary</clue>
<clue>"___ quam videri" (North Carolina's motto)</clue>
<clue>Tallied</clue>
</across>
<down>
<clue>Dutch cheese</clue>
<clue>Drink</clue>
<clue>Actress Sofer</clue>
<clue>Perceived to be</clue>
<clue>Ivory Coast's largest city</clue>
<clue>Lisa, to Bart, briefly</clue>
<clue>Therefore</clue>
<clue>Stack of firewood</clue>
<clue>Take pleasure in</clue>
<clue>Drain</clue>
<clue>500 sheets</clue>
<clue>Lens holders</clue>
<clue>My ___, Vietnam</clue>
<clue>Red Bordeaux</clue>
<clue>Preserve</clue>
<clue>Perform</clue>
<clue>Printing widths</clue>
<clue>Suffocate</clue>
<clue>Puget Sound city</clue>
<clue>Swiss river</clue>
<clue>Did penance</clue>
<clue>Swedish soprano Jenny</clue>
</down>
</clues>
<hints>
<across>
<hints></hints>
<hints></hints>
<hints></hints>
<hints></hints>
<hints></hints>
<hints></hints>
<hints></hints>
</across>
<down>
<hints></hints>
<hints></hints>
<hints></hints>
<hints></hints>
<hints></hints>
<hints></hints>
<hints></hints>
</down>
</hints>
</grid>
我沒有在提示輸入呢,但他們將在那裏發佈之前。
你只有這個數據或更多的數據進來的XML文件請給我的XML整個格式我會給一個解析代碼,它是更好的,然後nsxml分析器。 – parag 2012-03-31 18:00:58
嗨。感謝你的快速回復。我編輯了我的文章,以便您可以看到整個XML文件 – 2012-04-04 05:56:06
您可以讓代碼解析完整的XML文件嗎? :) – 2012-04-05 15:26:42