2013-02-22 1 views
0

다음과 같은 XML을 구문 분석하려고합니다.iOS에서 XML 구문 분석

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
<soap:Body> 
    <WM_Login_MobileAppResponse xmlns="A.MobileAppService"> 
     <WM_Login_MobileAppResult> 
      <Login xmlns=""> 
       <Customer_Type>5</Customer_Type> 
       <Token>token</Token> 
      </Login> 
     </WM_Login_MobileAppResult> 
    </WM_Login_MobileAppResponse> 
</soap:Body> 

나는 문서를 구문 분석 NSXMLParsesr을 시도했다. 내가 사용하고있는 코드는 다음과 같습니다

(
    { 
    "Customer_Type" = 4; 
    Login = "token"; 
    Token = "token"; 
    "WM_Login_MobileAppResult" = "token"; 
} 
) 

누군가가 나에게 적절한 응답을 얻을 도와주세요 수 :

-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict 
{ 

if ([elementName isEqualToString:@"WM_Login_MobileAppResult"]) { 
    _resultDict = [[NSMutableDictionary alloc] init]; 
} 
} 

-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName 
{ 

[_resultDict setObject:_currentString forKey:elementName]; 
if ([elementName isEqualToString:@"WM_Login_MobileAppResult"]) { 
    [_array addObject:_resultDict]; 
    _resultDict = nil; 
} 
} 

-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string 
{ 
_currentString = [[NSString alloc] initWithString:string]; 
} 

이것은 내가 무엇입니까 결과는?

+0

을 "로그인"을 "WM_Login_MobileAppResult"로 변경해야한다고 생각? – GeneralMike

+0

실제로 얻을 것으로 예상되는 것은 무엇입니까? –

+0

'Token'및 'Customey_Type'에 대해서만 값을 저장하려고합니다. –

답변

0

난 당신이 당신이 게시 된 XML 문자열`Login`와`WM_Login_MobileAppResult` 얻을 것으로 예상된다 무엇