Home Ask Login Register

Developers Planet

Your answer is one click away!

DaViDa February 2016

XMLPullParser android colon tags

I have found several questions of the name question, but can't get any of them to work. What I want is to get the url of the media:thumbnail tag:

<media:thumbnail width="144" height="81" url="http://c.files.bbci.co.uk/6013/production/_88159542_3e6f2bc3-16a3-407d-9e07-62bae1fa755e.jpg"/>

Above the example of such tag

private void handleText(String text) {
            String xmlText = text;
            if (currentEntry != null && currentTag != null) {
                if (currentTag.equals(TITLE)) {
                } else if (currentTag.equals(DESC)) {
                } else if (currentTag.equals(LINK)) {
                } else if (currentTag.equals(IMAGE)) {

I tried several things as:

xpp.getAttributeValue(null, "url"); and set the image as that. However I noticed that I am not even getting in that else if clause. I tried several values on the IMAGE variable like:

  • media:thumbnail
  • media
  • thumbnail

I have also set namespace aware:


What am I doing wrong?


XmlPullParser xpp;
int eventType;

protected List<Entry> doInBackground(String... string) {
    try {

        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        xpp = factory.newPullParser();
        xpp.setInput(getInputStream(new URL("http://feeds.bbci.co.uk/news/technology/rss.xml?edition=uk")), "UTF_8");

        eventType = xpp.getEventType();
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_TAG) {


DaViDa February 2016

I fixed it. I systemed out the start tags it was parsing and it showed up as: thumbnail. So I changed my IMAGE constant to have the value of "thumbnail". It never came in the thumbnail clause since the handleText method only handles found text in a tag. Since media:thumbnail has no text only attributes with values I needed to handle it in the handleStartTag method. There I could say if the current tag name equals "thumbnail" get the attribute value of url and setImage as that value.

Post Status

Asked in February 2016
Viewed 2,617 times
Voted 10
Answered 1 times


Leave an answer

Quote of the day: live life