我正在尝试从Web服务获取XML,执行以下操作:
NSString *areaDescriptionWSpaceCharacters = [areaDescription componentsJoinedByString:@","];
areaDescriptionWSpaceCharacters = [areaDescriptionWSpaceCharacters stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
NSString *requestString = [NSString stringWithFormat:@"%@?areaDescriptionPLXml=%@",kIP,areaDescriptionWSpaceCharacters];
NSURL *JSONURL = [NSURL URLWithString:requestString];
NSURLResponse* response = nil;
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:JSONURL];
NSData* data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:nil];
if(data == nil)
return nil;
NSError *myError;
NSDictionary *punchList = [[NSDictionary alloc]initWithDictionary:[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&myError]];
但是我收到了这个错误:
[0] (null) @"NSDebugDescription" : @"JSON text did not start with array or object and option to allow fragments not set." for `myError`
这是我的XML:
<ArrayOfKeyValueOfstringPunchListCellModel84zsBx89>
<KeyValueOfstringPunchListCellModel84zsBx89>
<Key>ORC0023</Key>
<Value>
<baseOrSchedStartList>
<string>2015-09-11T08:00:00</string>
<string>2015-08-10T16:00:00</string>
<string>2015-08-11T16:00:00</string>
</baseOrSchedStartList>
</Value>
</KeyValueOfstringPunchListCellModel84zsBx89>
</ArrayOfKeyValueOfstringPunchListCellModel84zsBx89>
我做错了什么?
答案 0 :(得分:3)