-2
如何解碼XML DOM在媒體解析:這是我的XML鏈接縮略圖標籤 :http://indianexpress.com/section/sports/feed/
如何解碼XML DOM在媒體解析:這是我的XML鏈接縮略圖標籤 :http://indianexpress.com/section/sports/feed/
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);
}