2010-06-17 58 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 ......其有据可查的,并可能是最快的,最好的解析器。