Q&D RSS in Website einbauen
<%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:XmlDataSource ID="XmlDataSource1" runat="server" XPath="rss/channel/item" CacheDuration="600" DataFile="http://www.aspnet-professional.de/newsrss.aspx"> </asp:XmlDataSource> <asp:datalist id="DataList1" runat="server" datasourceid="XmlDataSource1"> <itemtemplate> <a href="<%# XPath("link") %>" target="_blank"><%#XPath("title") %></a> <br /> </itemtemplate> </asp:datalist> </div> </form> </body> </html>
RSS mit ETAG erzeugen
<%@ Page Language="VB" ContentType="text/xml" EnableViewState="false" %> <script runat="server"> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Dim fakeetag As String = "xxx01" Dim etag As String = Request.Headers.Get("If-None-Match") Response.Cache.SetCacheability(HttpCacheability.Public) Response.Cache.SetETag(fakeetag) If fakeetag = etag Then Response.StatusCode = 304 Response.Flush() Response.End() Repeater1.Visible = False End If End Sub </script> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT [OrderID], [CustomerID], [RequiredDate], [ShipName] FROM [Orders]"> </asp:SqlDataSource> <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1"> <HeaderTemplate> <rss version="2.0"> <channel> <title>ppedv Bestellungen</title> <link>http://www.ppedv.de</link> <image><url>http://www.ppedv.de/ppedvk.gif</url></image> </HeaderTemplate> <FooterTemplate> </channel> </rss> </FooterTemplate> <ItemTemplate> <item> <title><%#librss.FormatForXML(Eval("shipname"))%></title> <link>http://www.ppedv.de/orders.aspx?id=<%#librss.FormatForXML(Eval("orderid"))%></link> <author><%#librss.FormatForXML(Eval("customerid"))%></author> <pubDate><%#librss.FormatForXML(Eval("requireddate", "{0:r}"))%></pubDate> </item> </ItemTemplate> </asp:Repeater>
Winforms VB 2005 RSS Reader nach allen regeln der Kunst (GZIP, ETAG)
Imports System.net Imports System.io Imports System.Xml Public Class Display Private ds As DataSet Private etag As String Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim reqRSS As HttpWebRequest = WebRequest.Create(txtRSSUrl.Text) reqRSS.Accept = "*/*" reqRSS.UserAgent = "Mozilla/4.0 (ppedv RSS Reader;)" reqRSS.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate") reqRSS.Headers.Set(HttpRequestHeader.IfNoneMatch, etag) Try Dim resRSS As HttpWebResponse = CType(reqRSS.GetResponse(), HttpWebResponse) Dim streamRSS As Stream = resRSS.GetResponseStream() If String.Compare(resRSS.ContentEncoding, "gzip", True) = 0 Then Dim gzipRSS As New Compression.GZipStream(streamRSS, Compression.CompressionMode.Decompress) ds.ReadXml(gzipRSS) gzipRSS.Close() Else Dim RSS As New StreamReader(streamRSS) ds.ReadXml(RSS) RSS.Close() End If streamRSS.Close() etag = resRSS.Headers.Get("ETag") resRSS.Close() ToolStripStatusLabel1.Text = Date.Now.ToLongTimeString + ": 200 " Catch ex As WebException If CType(ex.Response, HttpWebResponse).StatusCode = HttpStatusCode.NotModified Then ToolStripStatusLabel1.Text = Date.Now.ToLongTimeString + ": 304" End If End Try DataGridView1.DataSource = ds.Tables("item").DefaultView End Sub Private Sub txtIntervall_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtIntervall.TextChanged Timer1.Interval = CInt(txtIntervall.Text) * 1000 If Len(txtRSSUrl.Text) > 1 Then Timer1.Enabled = True End If End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load ds = New DataSet End Sub End Class
(c) Hannes Preishuber 2005
Deutsche ASP.NET News
Neue Preview-Version von Deep Zoom Composer
Windows Live Tools for Microsoft Visual Studio
Webseiten auf Internet Explorer 8 vorbereiten
Umfassendes Handbuch zu Visual C# 2008 zum Gratis-Download
Gratis eBook "Microsoft Visual Basic 2008 Neue Technologien – Crashkurs"
Gratis Microsoft-Software für Studenten
Silverlight 2 Beta 2 erschienen
Kostenloser Vortrag: Vortrag: Outlook 2007 & LINQ – Geht das? Was gibt es neues für die Office 2007 Entwicklung?
Kostenloses Seminar: Seminar: Der Weg in die Selbständigkeit – Gründungsworkshop für Informatiker
Microsoft Expression Studio 2 final
Weblogs ASP.NET
@
Silverlight 2.0 plugin ID or not ID
@
Bind with Expression Blend: cannot create Instance Exception
@
set as start page: Silverlight XAML
@
fast and furios Silverlight Databinding with Gridview and embedded XML Data Resources
@
IE 8 simultaneous connections changed
@
reverse engineering of Silverlight XAP files
@
What I miss in Silverlight 2.0
@
fixed: asp.net gridview dataformatstring
@
what I miss in LINQdatasource
@
want to be a .NET star **{*}**?
@
Visendo SMTP (pop3) Extender for Windows 2008 Server
@
Visual Studio IIS 7 and WebDAV
@
360° Visual Studio 2008, where we are?
@
AJAX drag& drop challenge: science fiction with web.preview
@
AJAX drag drop Challenge: new with profile support