Linq to XML 用一句话读出RSS文章列表代码
更新时间:2010年06月17日 14:52:31 作者:
Linq to XML 用一句话读出RSS文章列表代码
在页面的 Page_Load() 方法中写上这句话就行了:
new XDocument(
new XElement("ol",
from item in XDocument.Load("http://cnblogs.com/rss").Descendants("item")
select new XElement[]{
new XElement("li",
new XElement("a",(string)item.Element("title"),
new XAttribute("href",(string)item.Element("link"))
)
)
}
)
).WriteTo(new XmlTextWriter(Response.OutputStream,Encoding.UTF8));
复制代码 代码如下:
new XDocument(
new XElement("ol",
from item in XDocument.Load("http://cnblogs.com/rss").Descendants("item")
select new XElement[]{
new XElement("li",
new XElement("a",(string)item.Element("title"),
new XAttribute("href",(string)item.Element("link"))
)
)
}
)
).WriteTo(new XmlTextWriter(Response.OutputStream,Encoding.UTF8));
相关文章
详解如何在.NET代码中使用本地部署的Deepseek语言模型
这篇文章主要来和大家一起聊一聊怎么在 .NET 代码中使用本地部署的 Deepseek 语言模型,文中的示例代码简洁易懂,有需要的小伙伴可以了解下2025-02-02
ASP.NET MVC制作404跳转实例(非302和200)
本篇文章主要介绍了ASP.NET MVC制作404跳转实例(非302和200) ,具有一定的参考价值,感兴趣的小伙伴们可以参考一下2017-04-04
ASP.NET输出PNG图片时出现GDI+一般性错误的解决方法
偶原来的用ASP.NET生成验证码图片时用的是JPG格式,今天想把它改成PNG格式的,结果就出现GDI+一般性错误,查了N久资料,才发现解决的办法,对分享此解决办法的网友深表感谢2009-01-01


最新评论