something about you Bye Bye è; un saluto
我使用NSXMLParser,它是顺利,直到它找到èHTML实体。它要求foundCharacters:为“再见”,然后调用resolveExternalEntityName:systemID与::用“egrave”的的entityName。在该方法我只是返回字符“E”trasformed在一个NSData,所述foundCharacters再次调用添加字符串“E”前一个“再见”,然后解析器提高NSXMLParserUndeclaredEntityError错误。
我没有DTD和我不能改变的HTML文件即时解析。你对这个问题的任何想法?在此先感谢所有的GRIFFO的建议后,我结束了这样的事情:
data = [self replaceHtmlEntities:data];
NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
[parser setDelegate:self];
[parser parse];
- (NSData *)replaceHtmlEntities:(NSData *)data {
NSString *htmlCode = [[NSString alloc] initWithData:data encoding:NSISOLatin1StringEncoding];
NSMutableString *temp = [NSMutableString stringWithString:htmlCode];
[temp replaceOccurrencesOfString:@"&" withString:@"&" options:NSLiteralSearch range:NSMakeRange(0, [temp length])];
[temp replaceOccurrencesOfString:@" " withString:@" " options:NSLiteralSearch range:NSMakeRange(0, [temp length])];
...
[temp replaceOccurrencesOfString:@"À" withString:@"À" options:NSLiteralSearch range:NSMakeRange(0, [temp length])];
NSData *finalData = [temp dataUsingEncoding:NSISOLatin1StringEncoding];
return finalData;
}