2016-03-22 20 views
0

私は次のような応答を取得KSOAP2(3.0.0)を使用しています:Androidで複雑なksoapオブジェクトをStringに解析する方法は?

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" > 
     <env:Header> 
     </env:Header> 
     <env:Body> 
      <ns2:ExampleResponse xmlns:ns2="http://example.com/" > 
       <result> 
        <answer>0</answer> 
        <message> 
         <last>0</last> 
        </message> 
       </result> 
      </ns2:ExampleResponse> 
     </env:Body> 
    </env:Envelope> 

私はキャプチャしたい「最後、私は次のように使用:

String ans1 = response.getPropertyAsString("answer"); // 0 
String ans2 = response.getPropertyAsString("message"); // anyType{last=0; } 
String ans3 = response.getPropertyAsString("last"); // illegal property: last 

示すようにだけ働いているが」 」。 はどのように取得することができます "?答えは" 最後

答えて

1

次の試みることができる:

// Fetches message as soap object, rather than just its string representation 
SoapObject messageObject = (SoapObject) response.getProperty("message"); 

// Fetches last from above oject 
String lastAsString = messageObject.getPropertyAsString("last"); 

希望すると助かります!

+0

ありがとう@Mithun! – Rodrick

関連する問題