Example Analysis of parsing rss problem
RssTable.Rows.length) {break;} SyndEntry entry = (SyndEntry) entries.get (I); / * System.out.println ("title:" + entry.getTitle ()); System.out.println ("connection address:" + entry.getLink ()); SyndContent description = entry.getDescription (); System.out.println ("title introduction:" + description.getValue ()); System.out.println ("release time:" + entry.getPublishedDate ()) / / the following are the following parts of the Rss source: System.out.println ("title author: + entry.getAuthor ()); * / ci.adp.DataRow rssRow = rssTable.getDataRowByIndex (index); rssRow.setValue (" TITLE ", entry.getTitle ()); rssRow.setValue (" LINK ", entry.getLink ()); rssRow.setValue (" PUBDATE ", entry.getPublishedDate ()); rssRow.setValue (" SOURCE ", entry.getAuthor ()) / * / the category to which this title belongs is List categoryList = entry.getCategories (); if (categoryList! = null) {for (int m = 0; m)
< categoryList.size(); m++) { SyndCategory category = (SyndCategory) categoryList .get(m); System.out.println("此标题所属的范畴:" + category.getName()); } } */ index++; /* // 得到流媒体播放文件的信息列表 List enclosureList = entry.getEnclosures(); if (enclosureList != null) { for (int n = 0; n < enclosureList.size(); n++) { SyndEnclosure enclosure = (SyndEnclosure) enclosureList .get(n); System.out.println("流媒体播放文件:" + entry.getEnclosures()); } } */ } } catch (Exception e) { e.printStackTrace(); }org.dom4j.io.SAXReader saxReader = new org.dom4j.io.SAXReader();org.dom4j.Document document = saxReader.read(rssUrl);org.dom4j.Element channel = (org.dom4j.Element) document.getRootElement().element("channel"); int index =0; for (java.util.Iterator i = channel.elementIterator("item"); i.hasNext();){ if(index+1>RssTable.Rows.length) {break;} org.dom4j.Element element = (org.dom4j.Element) i.next (); String title = element.elementText ("title"); String link = element.elementText ("link"); String pubDate = element.elementText ("pubDate"); String source = element.elementText ("source"); ci.adp.DataRow rssRow = rssTable.getDataRowByIndex (index); rssRow.setValue ("TITLE", title); rssRow.setValue ("LINK", link); rssRow.setValue ("PUBDATE", pubDate) RssRow.setValue ("SOURCE", source); / * System.out.println ("title title:" + title); System.out.println ("link Link:" + link); System.out.println ("pubDate release time:" + pubDate); System.out.println ("source Source:" + source); * / index++ } this is the end of the article on "sample Analysis of parsing rss problems". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.