title: XML parsing with CDATA tag in it
body: <p>I have a <code>XML</code> coming from the API, it includes some ads to show up. Here is what <code>XML</code> looks like:</p>
  
  <pre><code>&lt;mojiva&gt;
  &lt;ad type="image"&gt;
  &lt;url&gt;
  &lt;![CDATA[
  http://google.com
  ]]&gt;
  &lt;/url&gt;
  &lt;img type="image/png"&gt;
  &lt;![CDATA[
  http://account.mobfox.com/activation_vad.php
  ]]&gt;
  &lt;/img&gt;
  &lt;track&gt;
  &lt;![CDATA[
  http://ads.moceanads.com/2/img/c2d79d40-6182-11e3-8f06-a0369f167751
  ]]&gt;
  &lt;/track&gt;
  &lt;/ad&gt;
  &lt;/mojiva&gt;
  </code></pre>
  
  <p>In this I two things to parse the <code>&lt;url&gt;</code> tag and the <code>&lt;img&gt;</code> tag for showing it properly inside my app. There is a case of <code>CDATA</code> coming inside both the tags. </p>
  
  <p>How can I parse just the mentioned tags without <code>CDATA</code> to get url and show it.
  Any kind of help will be appreciated.</p>
  
  <p><strong>Updated code(Using XMLPullParser):</strong></p>
  
  <pre><code>public class AdPull {
  
  private static final String demoURL = null;
  
  public AdPull(InputStream open) {
      try {
          XmlPullParser parser = Xml.newPullParser();
          parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
          parser.setInput(open, null);
          parser.nextTag();
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  
  private List&lt;Entry&gt; readFeed(XmlPullParser parser)
          throws XmlPullParserException, IOException {
      List&lt;Entry&gt; entries = new ArrayList&lt;Entry&gt;();
      parser.require(XmlPullParser.START_TAG, demoURL, "mojiva");
      while (parser.next() != XmlPullParser.END_TAG) {
          if (parser.getEventType() != XmlPullParser.START_TAG) {
              continue;
          }
          String name = parser.getName();
          if (name.equals("ad")) {
              entries.add(readAd(parser));
          } else {
              skip(parser);
          }
      }
      return entries;
  }
  
  private Entry readAd(XmlPullParser parser) throws XmlPullParserException,
          IOException {
      parser.require(XmlPullParser.START_TAG, demoURL, "ad");
      String url = null;
      String image = null;
      while (parser.next() != XmlPullParser.END_TAG) {
          if (parser.getEventType() != XmlPullParser.START_TAG) {
              continue;
          }
          String name = parser.getName();
          if (name.equals("url")) {
              url = readUrl(parser);
          } else if (name.equals("img")) {
              image = readImage(parser);
          } else {
              skip(parser);
          }
      }
      return new Entry(url, image);
  }
  
  private String readUrl(XmlPullParser parser) throws IOException,
          XmlPullParserException {
      parser.require(XmlPullParser.START_TAG, demoURL, "url");
      String url = readText(parser);
      parser.require(XmlPullParser.END_TAG, demoURL, "url");
      return url;
  }
  
  private String readImage(XmlPullParser parser) throws IOException,
          XmlPullParserException {
      parser.require(XmlPullParser.START_TAG, demoURL, "img");
      String image = readText(parser);
      parser.require(XmlPullParser.END_TAG, demoURL, "img");
      return image;
  }   
  
  private String readText(XmlPullParser parser) throws IOException,
          XmlPullParserException {
      String result = "";
      if (parser.next() == XmlPullParser.TEXT) {
          result = parser.getText();
          parser.nextTag();
      }
      return result;
  }
  
  private void skip(XmlPullParser parser) throws XmlPullParserException,
          IOException {
      if (parser.getEventType() != XmlPullParser.START_TAG) {
          throw new IllegalStateException();
      }
      int depth = 1;
      while (depth != 0) {
          switch (parser.next()) {
          case XmlPullParser.END_TAG:
              depth--;
              break;
          case XmlPullParser.START_TAG:
              depth++;
              break;
          }
      }
  }
  
  public static class Entry {
      public final String adURL;
      public final String adImage;
  
      private Entry(String url, String image) {
          this.adURL = url;
          this.adImage = image;
      }
  }
  }
  </code></pre>
  
  <p>And here is my async task where I want to print the values of the <code>XML</code> feeds:</p>
  
  <pre><code>class AsyncTaskRunner extends AsyncTask&lt;String, String, String&gt; {
  
      @Override
      protected String doInBackground(String... params) {
  
          try {
              DefaultHttpClient httpclient = new DefaultHttpClient();
              HttpGet httppost = new HttpGet(completeURL);
              HttpResponse response = httpclient.execute(httppost);
              HttpEntity ht = response.getEntity();
              String _respons = EntityUtils.toString(ht);
              InputStream is = new ByteArrayInputStream(_respons.getBytes());
              new AdPull(is);
  
          } catch (Exception e) {
              e.printStackTrace();
          }
  
          return null;
      }
  }
  </code></pre>
  
  <p>But, this is giving me error, whenever I'm passing the completeURL inside it <code>The constructor parserPull(String) is undefined</code></p>
  
  <p>What am I doing wrong here?</p>