TouchXML parsing error
I have a xml document which has only one element in the document. This is the whole document.
<?xml version="1.0" encoding="UTF-8"?>
<error>key ! is invalid</error>
But when i try to parse it, it says this document has no element at all. In other words when i try to access the rootElement it says "null"
Here is the code i am using.
CXMLDocument *rssParser = [[[CXMLDocument alloc] initWithContentsOfURL:url options:0 error:nil] autorelease];
NSLog(@"Root: %@",[[rssParser rootElement] name]);
But its working OK when i have the following document.
<?xml version="1.0" encoding="UTF-8"?>
<response>
<list><cate开发者_如何学运维gory>(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>
Please tell me what is wroing with this.
Thanks
If your up for trying a different parser, I would recommend using TBXML ...its well documented and probably the fastest and best parser around.
精彩评论