我从服务器加载 XML 响应并使用 NSXMLParser 进行解析。模拟器没有错误。但在 iPhone 中显示 NSXMLParserErrorDomain Code=5。
NSString *settings = "http://website.com/settings";
NSURL *url = [NSURL URLWithString:settings];
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:url];
xmlParser.delegate = self;
BOOL success = [xmlParser parse];
if(success)
{
NSLog(@"Parse Success");
}else{
NSLog(@"Parse Failure");
NSLog(@"Parse Error: %@",[xmlParser parserError]);
}
XML 响应
<?xml version="1.0" encoding="utf-8"?>
<Settings>
<AutoRefereshTime>10</AutoRefereshTime>
<CashierPasswordRequired>Y</CashierPasswordRequired>
<CheckoutTableColor>#FFFF00</CheckoutTableColor>
<CompanyLogo>http://website.com/UCS_WS/Images/Logo/Logo.png</CompanyLogo>
<CompanyName>UnoRestaurant</CompanyName>
<ConfirmedTableColor>008ED5</ConfirmedTableColor>
<Description>The Great Indian Restaurant</Description>
<DevelopedBy>Unipro</DevelopedBy>
<HoldTableColor>A02325</HoldTableColor>
<ImageURL>http://rwebsite.com/UCS_WS/Images/Dish/</ImageURL>
<isCategoryEnabled>Y</isCategoryEnabled>
<isOtherLanguageEnabled>Y</isOtherLanguageEnabled>
<NormalTableColor>#0000FF</NormalTableColor>
<OrderScreenView>POS View</OrderScreenView>
<OtherLanguage>Tamil</OtherLanguage>
<SharedTableColor>#00FFFF</SharedTableColor>
</Settings>
解析错误:
Error Domain=NSXMLParserErrorDomain Code=5 "The operation couldn’t be completed. (NSXMLParserErrorDomain error 5.)"