Jaykishan Tanna Jaykishan Tanna - 25 days ago 25
Android Question

how to decode xml dom parsing at media:thumbnail tag

tag

how to decode xml dom parsing at media:thumbnail tag
here is my xml link : http://indianexpress.com/section/sports/feed/

Answer
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);
                }
Comments