title: Get data from XML in String - Android
body: <p>I'm using SOAP service to get ticket. I'm sending user and pass, and I'm getting xml in String. For this I'm using ksoap2.</p>
  
  <pre><code>@Override
  protected String doInBackground(String... params) {
  
      SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
      request.addProperty(USER, params[0]);
      request.addProperty(PASS, params[1]);
  
      SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
      soapEnvelope.bodyOut = request;
      soapEnvelope.setOutputSoapObject(request);
  
      HttpTransportSE HttpTransport = new HttpTransportSE(URL);
      try {
          HttpTransport.call(SOAP_ACTION, soapEnvelope);
          return soapEnvelope.getResponse().toString();
      } catch (IOException | XmlPullParserException e) {
          e.printStackTrace();
          return null;
      }
  }
  
  @Override
      protected void onPostExecute(String XML) {
          super.onPostExecute(XML);
          if (result != null) {
             // Here I need to get data from XML
  
          }
      }
  </code></pre>
  
  <p>My XML String looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;resp err="0"&gt;
  &lt;ticket&gt;1234567989&lt;/ticket&gt;
  &lt;/resp&gt;
  </code></pre>
  
  <p>So I need to get the error number, and the ticket number.</p>