我正在確定一個流是否存在或不存在。我有一個預先存檔的文件(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。 –