TouchXML - 无效的 XML 不返回错误对象
假设我有一个无效的 XML。由于某种原因,TouchXML 仍然将其视为有效对象。
例如:
NSString *str = @"?> obviously invalid!";
NSData *data = [str dataUsingEncoding:NSASCIIStringEncoding];
NSError *parseError = nil;
CXMLDocument *document = [[[CXMLDocument alloc] initWithData:data encoding:NSASCIIStringEncoding options:0 error:&parseError] autorelease];
NSLog(@"Error %i......%@", [parseError code], [parseError localizedFailureReason]);
NSLog(@"Document ......%@", [document description]);
输出是:
Error 0......(null)
Document ......<CXMLDocument 0x6f05710 [0x6f274c0]> <?xml version="1.0" encoding="us-ascii"?>
有人知道为什么会发生这种情况吗?我不会整理 XML...
谢谢!
Say I have an invalid XML. For some reason, TouchXML still sees it as a valid object.
For example:
NSString *str = @"?> obviously invalid!";
NSData *data = [str dataUsingEncoding:NSASCIIStringEncoding];
NSError *parseError = nil;
CXMLDocument *document = [[[CXMLDocument alloc] initWithData:data encoding:NSASCIIStringEncoding options:0 error:&parseError] autorelease];
NSLog(@"Error %i......%@", [parseError code], [parseError localizedFailureReason]);
NSLog(@"Document ......%@", [document description]);
The output is:
Error 0......(null)
Document ......<CXMLDocument 0x6f05710 [0x6f274c0]> <?xml version="1.0" encoding="us-ascii"?>
Does anybody know why this is happening? I'm not tidying up the XML...
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了解决这个问题的方法。出于
我的目的,我
改为
Found a way around this. Inside
For my purposes, I changed
to