2010-06-17 109 views
1

我有一個xml文檔,它在文檔中只有一個元素。這是整個文件。TouchXML解析錯誤

<?xml version="1.0" encoding="UTF-8"?> 
<error>key ! is invalid</error> 

但是,當我試圖解析它,它說這個文件根本沒有元素。換句話說,當我嘗試訪問rootElement它說「空」

這是我使用的代碼。

CXMLDocument *rssParser = [[[CXMLDocument alloc] initWithContentsOfURL:url options:0 error:nil] autorelease]; 

    NSLog(@"Root: %@",[[rssParser rootElement] name]); 

但它的工作正常,當我有以下文件。

<?xml version="1.0" encoding="UTF-8"?> 
<response> 
<list><category>(noun)</category><synonyms>angstrom|angstrom unit|A|metric linear unit</synonyms></list> 
<list><category>(noun)</category><synonyms>vitamin A|antiophthalmic factor|axerophthol|A|fat-soluble vitamin</synonyms></list> 
<list><category>(noun)</category><synonyms>deoxyadenosine monophosphate|A|nucleotide</synonyms></list> 
<list><category>(noun)</category><synonyms>adenine|A|purine</synonyms></list> 
<list><category>(noun)</category><synonyms>ampere|amp|A|current unit</synonyms></list> 

<list><category>(noun)</category><synonyms>A|letter a|letter|letter of the alphabet|alphabetic character</synonyms></list> 
<list><category>(noun)</category><synonyms>A|type A|group A|blood group|blood type</synonyms></list> 
</response> 

請告訴我什麼是這樣的。

感謝

+0

我已經更新了這個問題,顯示了我得到的整個文檔的迴應。 – itsaboutcode 2010-06-17 10:44:11

+0

我刪除了我的答案,因爲它顯然是錯誤的。對不起,我不能有更多的幫助。 – ChrisF 2010-06-17 10:51:17

回答

1

如果你的彌補嘗試不同的解析器,我會建議身邊使用TBXML ......其有據可查的,並可能是最快的,最好的解析器。