java - parse image in dom parser using jsoup in android -


i trying rss feed of website:

http://www.phonearena.com/feed

here domparser activity:

public class domparser { private rssfeed _feed = new rssfeed();  public rssfeed parsexml(string xml) {      url url = null;     try {         url = new url(xml);     } catch (malformedurlexception e1) {         e1.printstacktrace();     }      try {          documentbuilderfactory dbf;         dbf = documentbuilderfactory.newinstance();         documentbuilder db = dbf.newdocumentbuilder();           document doc = db.parse(new inputsource(url.openstream()));         doc.getdocumentelement().normalize();          nodelist nl = doc.getelementsbytagname("item");         nodelist itemchildren = null;         node currentitem = null;         node currentchild = null;         int length = nl.getlength();          (int = 0; < length; i++) {              currentitem = nl.item(i);             rssitem _item = new rssitem();              nodelist nchild = currentitem.getchildnodes();             int clength = nchild.getlength();               (int j = 0; j < clength; j++) {                  currentchild = nchild.item(j);                 string thestring = null;                 string nodename = currentchild.getnodename();                  thestring = nchild.item(j).getfirstchild().getnodevalue();                  if (thestring != null) {                     if ("title".equals(nodename)) {                          _item.settitle(thestring);                     }                      else if ("description".equals(nodename)) {                          _item.setdescription(thestring);                          // parse html description image url                         string html = thestring;                         org.jsoup.nodes.document dochtml = jsoup                                 .parse(html);                         elements imgele = dochtml.select("img");                         _item.setimage(imgele.attr("src"));                     }                      else if ("pubdate".equals(nodename)) {                           string formateddate = thestring.replace(" +0000",                                 "");                         _item.setdate(formateddate);                     }                  }             }               _feed.additem(_item);         }      } catch (exception e) {     }       return _feed; } }      

everything working fine except image trying through jsoup.

can tell doing wrong or missing?

the variable thestring needs unescaped before passing jsoup.

else if ("description".equals(nodename)) {     _item.setdescription(thestring);      // unescape parse html description image url     element imgele = jsoup.parse( //             parser.unescapeentities( //                   parser.xmlparser().parseinput(thestring, "").outerhtml(), //                   true //             )) //             .select("img").first();      if (imgele != null) {         _item.setimage(imgele.attr("src"));     } } 

Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -