我正在确定一个流是否存在或不存在。我有一个预先存档的文件(http://www.calvaryccm.com/ServiceTimes.asmx/IsServiceTime)。这是当流处于非活动状态它返回什么:Android Xml检查webservice是否返回true或false
<boolean xmlns="http://tempuri.org/">false</boolean>
当流有效时,它返回此:
<boolean xmlns="http://tempuri.org/">true</boolean>
我需要帮助创建一个XML阅读器来检查Web服务返回true或false。感谢您的帮助。
我最近在iOS上做了同样的事情,这是我如何检查XML。
NSError * error = nil;
NSString * responseString = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://www.calvaryccm.com/ServiceTimes.asmx/IsServiceTime"] encoding:NSUTF8StringEncoding error:&error];
NSRange range = [responseString rangeOfString : @"true"];
if (range.location != NSNotFound) {
NSLog(@"%@", responseString);
/// Handle active content.
hiddenVideo.hidden = FALSE;
hiddenAudio.hidden = FALSE;
noService.hidden = TRUE;
}
else {
NSLog(@"%@", responseString);
// Inform user that the content is unavailable
hiddenVideo.hidden = TRUE;
hiddenAudio.hidden = TRUE;
noService.hidden = FALSE;
// Inform user that the content is unavailable
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle: @"Live Service"
message: @"There is no service going on at this time"
delegate: nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
HasShownAlert = TRUE; //let the other event know that the alert has already been shown.
}
有没有办法在Android中做类似的事情?
能否请您详细阐述了。我不明白你真的想要什么? –
我需要帮助创建一个XML读取器来检查Web服务是否返回true或false。 –