title: How to parse XML return from OkHttp?
body: <p>This is my OkHttp Post Form Parameter Method using OkHttp's Async Get</p>
  
  <pre><code>public Call postGetCountries(Callback callback) {
      RequestBody body = new FormEncodingBuilder()
          .add("op", "op")
          .build();
  
      Log.d(TAG_PARAMS, "op=sgetcountrylist, app_type=1");
  
      Request request = new Request.Builder()
          .url(GATEWAY_URL)
          .post(body)
          .build();
  
      Call call = CLIENT.newCall(request);
      call.enqueue(callback);
  
      return call;
  }
  </code></pre>
  
  <p>This is my custom Callback.</p>
  
  <pre><code>private class GetCountriesCallback implements Callback {
      @Override
      public void onFailure(Request request, IOException e) {
          Log.e("OkHttp", e.getMessage());
      }
  
      @Override
      public void onResponse(Response response) throws IOException {
          Log.d("PASSED", "PASS");
          Log.d(Connection.TAG_RETURN, response.body().string());
  
          try {
              InputStream is = response.body().byteStream();
              List test = connectionParser.parse(is, "op");
  
          } catch (XmlPullParserException e) {
              Log.e("PARSE ERROR", e.getMessage());
          }
      }
  }
  </code></pre>
  
  <p>This is my instantiated parse method.</p>
  
  <pre><code>public List parse(InputStream in, String op) throws XmlPullParserException, IOException {
      try {
          XmlPullParser parser = Xml.newPullParser();
          parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
          parser.setInput(in, null);
          parser.nextTag();
          return readFeed(parser, op);
      } finally {
          in.close();
      }
  }
  </code></pre>
  
  <p>I'm currently testing if it works unfortunately I receive a return of</p>
  
  <pre><code>10-06 11:54:42.492 6336-6892/ D/PASSED: PASS
  10-06 11:54:42.692 6336-6892/ E/PARSE ERROR: Invalid stream or encoding: java.io.IOException: closed (position:START_DOCUMENT null@1:1) caused by: java.io.IOException: closed
  </code></pre>
  
  <p>This is what I use on my onCreate on the activity to start the whole process:</p>
  
  <pre><code>private Connection connect = Connection.getInstance();
  connect.postGetCountries(new GetCountriesCallback());
  </code></pre>
  
  <p>I don't understand as to why the InputStream gets closed.</p>