title: Processing RSS Feeds with Namespaces in Android
body: <p>I'm trying to write an XML parser that takes an RSS feed &amp; fetches the image urls shown in the url attribute of the <code>&lt;media:thumbnail&gt;</code> tag.  This is all being done via <code>android.Util.Xml</code>, &amp; is an adaptation of <a href="http://www.ibm.com/developerworks/opensource/library/x-android/index.html#N101E0" rel="nofollow noreferrer">the code shown here</a>.  An example RSS feed that I'm trying to use is the <a href="http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml" rel="nofollow noreferrer">BBC News RSS feed</a>.</p>
  
  <p>However, media is an additional namespace &amp; (probably) as a result my parser isn't working as it should.</p>
  
  <p>A version of my parse method is below.  Is there any (no doubt simple) way to get my list of image URLs working?</p>
  
  <pre><code>public List&lt;string&gt; parse() {
      URL feedUrl = new URL("http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml");
  
      InputStream feedStream;
  
      try {
          feedStream = feedUrl.openConnection().getInputStream();
      } catch (IOException e) {
          throw new RuntimeException(e);
      }              
  
      final List&lt;string&gt; ret = new ArrayList&lt;string&gt;();
  
      RootElement root = new RootElement("rss");
      Element channel = root.getChild("channel");
      Element item = channel.getChild("item");
  
      item.getChild("media", "thumbnail").getChild("url").setEndTextElementListener(new EndTextElementListener() {
          public void end(String body) {
              ret.add(body);
          }
      });
  
      try {
          Xml.parse(feedStream, Xml.Encoding.UTF_8, root.getContentHandler());
      } catch (Exception e) {
          throw new RuntimeException(e);
      }
  
      return ret;
  }
  </code></pre>