I have My RSS File Items :
<item >
<title>Prasad</title>
<link>http://www.tele.com/rssHostDescr.php?hostId=15</link>
<guid isPermaLink="false">http://www.tele.com/rssHostDescr.php?hostId=14</guid>
<pubDate>2013-04-10</pubDate>
<description>Prasad</description>
<media:thumbnail width='66' height='49' url='http://www.tele.com/hos/Panthi-image.jpg'></media:thumbnail>
</item>
<item>
........................
</item>
etc.....................
I'm trying to parse the above file,I'm able to get all the information(title,link,date)but my requirement is to get url attribute value,How to get the URL value from media:thumbnail tag? Could any one help?
here my code:
public class HostsRssHandler extends DefaultHandler {
private List<HostsProfile> messages;
private HostsProfile currentMessage;
private StringBuilder builder;
public List<HostsProfile> getMessages(){
return messages;
}
@Override
public void characters(char[] ch, int start, int length)
throws SAXException {
super.characters(ch, start, length);
builder.append(ch, start, length);
}
@Override
public void endElement(String uri, String localName, String name)
throws SAXException {
super.endElement(uri, localName, name);
if (this.currentMessage != null){
if (localName.equalsIgnoreCase("tilte")){
currentMessage.setTitle(builder.toString());
} else if (localName.equalsIgnoreCase("link")){
currentMessage.setLink(builder.toString());
}
else if (localName.equalsIgnoreCase("media:thumbnail")){
currentMessage.setMediathumbnail(builder.toString());
}
else if (localName.equalsIgnoreCase("pubDate")){
currentMessage.setDate(builder.toString());
}
else if (localName.equalsIgnoreCase("item")){
messages.add(currentMessage);
}
builder.setLength(0);
}
}
@Override
public void startDocument() throws SAXException {
super.startDocument();
messages = new ArrayList<HostsProfile>();
builder = new StringBuilder();
}
@Override
public void startElement(String uri, String localName, String name,
Attributes attributes) throws SAXException {
super.startElement(uri, localName, name, attributes);
if (localName.equalsIgnoreCase("item")){
this.currentMessage = new HostsProfile();
}
}
}
Note:
else if (localName.equalsIgnoreCase("media:thumbnail")){
currentMessage.setMediathumbnail(builder.toString());// During My Program Execution, Here I'm not able to get any value
}