2011-09-08 3 views
1

스트림이 실제로 있는지 여부를 확인하려고합니다. 나는 그 파일을 가지고있다 (http://www.calvaryccm.com/ServiceTimes.asmx/IsServiceTime). 스트림이 활성화되면webservice가 true 또는 false를 반환하는지 Android Xml 확인

<boolean xmlns="http://tempuri.org/">false</boolean>

는이 반환 :이 스트림이 비활성 상태 일 때 그것을 반환 것입니다

<boolean xmlns="http://tempuri.org/">true</boolean>

나는 웹 서비스 여부를 확인하기 위해 XML 리더를 만드는 데 도움이 필요

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에서 이와 유사한 작업을 수행 할 수있는 방법이 있습니까?

+0

에 대한 링크를 아래

을 사용하면 좀 더 자세히 설명해 수 있습니다. 네가 정말로 원하는 걸 이해할 수 없다? –

+0

webservice가 true 또는 false를 반환하는지 확인하기 위해 xml 리더를 만드는 데 도움이 필요합니다. –

답변

3

xml을 구문 분석해야합니다. xml을 구문 분석 한 후 부울 값 true 또는 flase를 얻을 수 있습니다. 그 다음에는 응용 프로그램에서 해당 값을 사용할 수 있습니다.

XML을 구문 분석하기 위해 안드로이드 XML PULL 구문 분석기가 가장 좋습니다. 그것을 사용하여 XML을 구문 분석 할 수 있습니다. 자세한 내용

http://www.ibm.com/developerworks/opensource/library/x-android/

0

에 simepl 튜토리얼입니다.

Google을 사용하여 필요에 따라 JAVA 예제를 사용하여 XML 구문 분석을 찾으십시오.

관련 문제