Rss对返回的xml格式有一套严格的规定,详细模板见附件;
一般java读取xml
URL url = new URL(rss);
//读取Rss源
XmlReader reader = new XmlReader(url);
System.out.println("Rss源的编码格式为:" + reader.getEncoding());
SyndFeedInput input =new SyndFeedInput();
//得到SyndFeed对象,即得到Rss源里的所有信息
// SyndFeed feed =input.build(reader);
SyndFeed feed = input.build(new InputSource(url.openStream()));
//System.out.println(feed);
//得到Rss新闻中子项列表
List entries =feed.getEntries();
Entries格式:
SyndEntryImpl.contents[0].interface=interfacecom.sun.syndication.feed.synd.SyndContent
SyndEntryImpl.contents[0].type=html
SyndEntryImpl.contents[0].mode=null
SyndEntryImpl.updatedDate=null
SyndEntryImpl.link=http://iyanlei.com/java_titan.html
SyndEntryImpl.foreignMarkup[0]=[Element:<slash:comments [Namespace: http://purl.org/rss/1.0/modules/slash/]/>]
SyndEntryImpl.foreignMarkup[1]=[Element:<wfw:commentRss [Namespace: http://wellformedweb.org/CommentAPI/]/>]
SyndEntryImpl.links=[]
SyndEntryImpl.interface=interfacecom.sun.syndication.feed.synd.SyndEntry
SyndEntryImpl.uri=http://iyanlei.com/java_titan.html
SyndEntryImpl.enclosures=[]
SyndEntryImpl.titleEx.value=Java操作图数据库Titan
SyndEntryImpl.titleEx.interface=interfacecom.sun.syndication.feed.synd.SyndContent
SyndEntryImpl.titleEx.type=null
SyndEntryImpl.titleEx.mode=null
SyndEntryImpl.author=Ray
SyndEntryImpl.authors=[]
SyndEntryImpl.title=Java操作图数据库Titan
SyndEntryImpl.source=null
SyndEntryImpl.description.value=Titan简介Titan是一个分布式的图形数据库,特别为存储和处理大规模图形而优化。支持不同的分布式存储层Cassandra 1.1HBase 0.92内置实现 Blueprints grap...
SyndEntryImpl.description.interface=interfacecom.sun.syndication.feed.synd.SyndContent
SyndEntryImpl.description.type=text/html
SyndEntryImpl.description.mode=null
SyndEntryImpl.categories=[]
SyndEntryImpl.publishedDate=TueMay 19 15:55:08 CST 2015
SyndEntryImpl.wireEntry=null
SyndEntryImpl.modules[0].publishers=[]
SyndEntryImpl.modules[0].identifiers=[]
SyndEntryImpl.modules[0].subjects=[]
SyndEntryImpl.modules[0].coverages=[]
SyndEntryImpl.modules[0].subject=null
SyndEntryImpl.modules[0].rights=null
SyndEntryImpl.modules[0].date=TueMay 19 15:55:08 CST 2015
SyndEntryImpl.modules[0].type=null
SyndEntryImpl.modules[0].descriptions=[]
SyndEntryImpl.modules[0].sources=[]
SyndEntryImpl.modules[0].publisher=null
SyndEntryImpl.modules[0].creator=Ray
SyndEntryImpl.modules[0].formats=[]
SyndEntryImpl.modules[0].languages=[]
SyndEntryImpl.modules[0].title=null
SyndEntryImpl.modules[0].dates[0]=TueMay 19 15:55:08 CST 2015
SyndEntryImpl.modules[0].contributor=null
SyndEntryImpl.modules[0].description=null
SyndEntryImpl.modules[0].types=[]
SyndEntryImpl.modules[0].contributors=[]
SyndEntryImpl.modules[0].relation=null
SyndEntryImpl.modules[0].format=null
SyndEntryImpl.modules[0].interface=interfacecom.sun.syndication.feed.module.DCModule
SyndEntryImpl.modules[0].uri=http://purl.org/dc/elements/1.1/
SyndEntryImpl.modules[0].creators[0]=Ray
SyndEntryImpl.modules[0].source=null
SyndEntryImpl.modules[0].coverage=null
SyndEntryImpl.modules[0].relations=[]
SyndEntryImpl.modules[0].titles=[]
SyndEntryImpl.modules[0].rightsList=[]
SyndEntryImpl.modules[0].language=null
SyndEntryImpl.modules[0].identifier=null
System.out.println("标题:" + entry.getTitle());
System.out.println("连接地址:" + entry.getLink());
SyndContentdescription = entry.getDescription(); System.out.println("标题简介:" + description.getValue());
System.out.println("发布时间:" + entry.getPublishedDate());
//以下是Rss源可先的几个部分
System.out.println("标题的作者:" + entry.getAuthor());
标题:Java操作图数据库Titan
连接地址:http://iyanlei.com/java_titan.html
标题简介:Titan简介Titan是一个分布式的图形数据库,特别为存储和处理大规模图形而优化。支持不同的分布式存储层Cassandra 1.1HBase 0.92内置实现 Blueprints grap...
发布时间:Tue May 19 15:55:08 CST 2015
标题的作者:Ray