NSXMLParserErrorDomain error 5 when parsing XML page
I am trying to parse an XML page in Objective-C. The full text of the error is:
Error Domain=NSXMLParserErrorDomain Code=5 "The operation couldn’t be completed. (NSXMLParserErrorDomain error 5.)"
I am attempting to parse the page like so:
NSURL *xmlUrl = [NSURL fileURLWithPath:@"xmlpage"];
NSXMLParser *xmlDoc = [[NSXMLParser alloc] initWithContentsOfURL: xmlUrl];
XMLParser *parser = [[XMLParser alloc]init];
Would appreciate any help, than开发者_C百科k you.
It's not clear to me what you are doing. You create a NSXMLParser, but call it a doc. Which it isn't. You then create a XMLParser which is a ? Some third party API perhaps ?
I don't have my code in front of me, but basically you need to setup a NSXMLParser delegate which can receive the XML element as the parser reads them. You then need to tell the parser to start processing the XML.
Another thing to look at is to confirm that the URL is actually sourcing XML and not some other content.
精彩评论