如何在媒体上解码xml dom解析:thumbnail标签 这是我的xml链接:http://indianexpress.com/section/sports/feed/
答案 0 :(得分:2)
try
{
XMLParser xmlParser = new XMLParser();
//result string is xml result
Document document = xmlParser.getDomElement(result);
NodeList nodeList = document.getElementsByTagName("item");
for (int i = 0; i < nodeList.getLength(); i++)
{
Element element = (Element) nodeList.item(i);
String title = xmlParser.getValue(element, "title");
String link = xmlParser.getValue(element, "link");
String pubdate = xmlParser.getValue(element, "pubDate");
NodeList media = element.getElementsByTagName("media:thumbnail");
Element elementMedia = (Element) media.item(0);
String url = elementMedia.getAttribute("url");
utils = new DataUtils();
utils.setProductName(title);
utils.setProductDate(pubdate);
utils.setProductDesc(link);
utils.setProductImage(url);
dataList.add(utils);
}