在Android中解析soap响应(字符串)

在Android中解析soap响应(字符串),android,soap,ksoap2,android-ksoap2,Android,Soap,Ksoap2,Android Ksoap2,我将来自HttpPost的Soap响应作为字符串 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <ns2:EnrollProfileResponse xmlns="http://www.myserver.com/ws/de" xmlns:ns2="http://www.myserver.com/ws/identityx" xmlns:ns

我将来自HttpPost的Soap响应作为字符串

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

<soap:Body>
    <ns2:EnrollProfileResponse xmlns="http://www.myserver.com/ws/de" xmlns:ns2="http://www.myserver.com/ws/identityx" xmlns:ns3="http://www.myserver.com/de/metadata">

        <ResponseStatus>
            <ReturnCode>100</ReturnCode>
            <Message>SUCCESS</Message>
            <Description>Device Success</Description>
        </ResponseStatus>
    </ns2:EnrollProfileResponse>
</soap:Body>

</soap:Envelope>

你能告诉我解析此响应的最佳方法吗?使用Android解析器之一。最流行的是XmlPullParser,如下所述:

有一个非常简单的例子告诉你一切:

 public class SimpleXmlPullApp
 {

     public static void main (String args[])
         throws XmlPullParserException, IOException
     {
         XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
         factory.setNamespaceAware(true);
         XmlPullParser xpp = factory.newPullParser();

         xpp.setInput( new StringReader ( "<foo>Hello World!</foo>" ) );
         int eventType = xpp.getEventType();
         while (eventType != XmlPullParser.END_DOCUMENT) {
          if(eventType == XmlPullParser.START_DOCUMENT) {
              System.out.println("Start document");
          } else if(eventType == XmlPullParser.START_TAG) {
              System.out.println("Start tag "+xpp.getName());
          } else if(eventType == XmlPullParser.END_TAG) {
              System.out.println("End tag "+xpp.getName());
          } else if(eventType == XmlPullParser.TEXT) {
              System.out.println("Text "+xpp.getText());
          }
          eventType = xpp.next();
         }
         System.out.println("End document");
     }
 }

您也可以在Vogella上看到:

是的,谢谢。我希望得到使用XmlPullParser或SaxParser的提示。