import java.io.*;
import java.net.URL;
import java.util.List;import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;/**
* @author Administrator TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
*/
public class JDomTest
{ public static void main(String args[])
{
try
{
SAXBuilder builder = new SAXBuilder();
try{
Document d = builder.build(new URL("http://bbs.chinaunix.net/rss/46.xml"));
Element root = d.getRootElement();
Element c = root.getChild("channel");
List list = c.getChildren("item");
for(int i=0;i<list.size();i++)
{
Element dd = (Element)list.getLight Bulb;
System.out.println(dd.getChild("title").getText()+dd.getChild("pubDate").getText());
// System.out.println(dd.getChild("author").getText()+dd.getChild("description").getText());
}
}catch(Exception e){
} }
catch (Exception e)
{
System.out.println(e.getMessage()); } }}
结果,,最后一行显示不正确:
(上)本土Linux企业的跌宕浮沉 2006-03-22 10:52:05
(中)本土Linux企业的跌宕浮沉 2006-03-22 10:48:15
ZT: 掌声响起来 为Solaris喝彩 2006-03-22 10:44:59
(下)本土Linux企业的跌宕浮沉 2006-03-22 10:43:21
红帽欲简化CPU虚拟化过程 整合源代码Xen技术 2006-03-22 10:39:05
Novell公布产品路线图 Linux黄金期将至 2006-03-22 10:37:38
WAPI受挫的启示 2006-03-22 10:36:46
广东省政、企、学各界合力推进LINUX政务应用 2006-03-22 10:30:39
Novell开发路线图强调开源软件巨大商机 2006-03-22 10:28:29
中国不当美国的替罪羊 2006-03-22 10:12:33
中国可能2年内不会批准VOIP 2006-03-22 10:06:03
Ubuntu Dapper将推迟6周发布 2006-03-22 09:58:56
再说Google OS 2006-03-22 09:57:17
索尼在线购开源数据库,甲骨文高价遭抛弃 2006-03-22 09:55:50
地球上最快的矢量图形软件 Xrar LX 2006-03-22 09:53:36
“傻瓜式”域名注册现身网络 2006-03-22 09:45:21
秘鲁总统批准政府采用开源软件 2006-03-22 09:42:38
警惕通信价格欺诈中的“炒蛋策略” 2006-03-22 09:39:38
中国百余网站将联合封堵垃圾邮件服务器IP地址 2006-03-22 09:37:39
IBM全面反?粑④??u?? 嘲?S其商?I模式?^?r 2006-03-22 09:30:25
import java.net.URL;
import java.util.List;import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;/**
* @author Administrator TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
*/
public class JDomTest
{ public static void main(String args[])
{
try
{
SAXBuilder builder = new SAXBuilder();
try{
Document d = builder.build(new URL("http://bbs.chinaunix.net/rss/46.xml"));
Element root = d.getRootElement();
Element c = root.getChild("channel");
List list = c.getChildren("item");
for(int i=0;i<list.size();i++)
{
Element dd = (Element)list.getLight Bulb;
System.out.println(dd.getChild("title").getText()+dd.getChild("pubDate").getText());
// System.out.println(dd.getChild("author").getText()+dd.getChild("description").getText());
}
}catch(Exception e){
} }
catch (Exception e)
{
System.out.println(e.getMessage()); } }}
结果,,最后一行显示不正确:
(上)本土Linux企业的跌宕浮沉 2006-03-22 10:52:05
(中)本土Linux企业的跌宕浮沉 2006-03-22 10:48:15
ZT: 掌声响起来 为Solaris喝彩 2006-03-22 10:44:59
(下)本土Linux企业的跌宕浮沉 2006-03-22 10:43:21
红帽欲简化CPU虚拟化过程 整合源代码Xen技术 2006-03-22 10:39:05
Novell公布产品路线图 Linux黄金期将至 2006-03-22 10:37:38
WAPI受挫的启示 2006-03-22 10:36:46
广东省政、企、学各界合力推进LINUX政务应用 2006-03-22 10:30:39
Novell开发路线图强调开源软件巨大商机 2006-03-22 10:28:29
中国不当美国的替罪羊 2006-03-22 10:12:33
中国可能2年内不会批准VOIP 2006-03-22 10:06:03
Ubuntu Dapper将推迟6周发布 2006-03-22 09:58:56
再说Google OS 2006-03-22 09:57:17
索尼在线购开源数据库,甲骨文高价遭抛弃 2006-03-22 09:55:50
地球上最快的矢量图形软件 Xrar LX 2006-03-22 09:53:36
“傻瓜式”域名注册现身网络 2006-03-22 09:45:21
秘鲁总统批准政府采用开源软件 2006-03-22 09:42:38
警惕通信价格欺诈中的“炒蛋策略” 2006-03-22 09:39:38
中国百余网站将联合封堵垃圾邮件服务器IP地址 2006-03-22 09:37:39
IBM全面反?粑④??u?? 嘲?S其商?I模式?^?r 2006-03-22 09:30:25
解决方案 »
- 关于计算机的几个专业方向
- public void paint(Graphics g)这句不知道是什么意思?
- 一个作业题目.急
- 求一个sql写法
- 在线跪求问题解决
- 我想问一下,javax和java包是放在哪个.jar文件中
- 局域网socket传输安全吗?????
- 这个问题怎么搞定?是不是CLASSPATH没有设定好?
- 用IE打开Applet小程序,没有运行结果;倒是用appletviwer打开,可以正确显示。
- 请教一个初级问题,我不会JAVA,.class是不是经过编译的java程序,能用什么软件打开吗
- Integer.valueOf()在win2000中是不是不好用啊?
- 如何把接收到的"\\u4F60\\u597D"转换成正确的中文形式打出来?
下面是我做的:http://www.latea.com.cn/readrss/
就是对所有的编码进行了转换才能正常运行!
怎么用法?在哪用.能给点代码吗?
InputStreamReader inStreamRead= new InputStreamReader(fileInput,"GBK");
document = saxbuilder.build(inStreamRead);