locked
RSS

    Question

  • Is there anyway of streaming RSS Feed into a window? (I have VB Express 2005)

    Please HELP!

     

    Josh.R - just become a member

    Thursday, November 13, 2008 1:39 PM

Answers

  • Here is some code that will load an RSS feed off the internet into a XML nodes list.
            Try
                Dim rssUrl = FeedTB.Text
                Dim rssRequest As System.Net.WebRequest = System.Net.WebRequest.Create(rssUrl)
                Dim rssResponse As System.Net.WebResponse = rssRequest.GetResponse()
                Dim rssStream = rssResponse.GetResponseStream()
            Catch ex As Net.WebException
                MsgBox("URL not found.", MsgBoxStyle.Critical, "RSS Tick")
                Exit Sub
            End Try

            Dim rssDoc As New System.Xml.XmlDocument
            Try
                rssDoc.Load(rssStream)
            Catch ex As Xml.XmlException
                MsgBox("URL not a valid RSS document.", MsgBoxStyle.Critical, "RSS Tick")
                Cursor = Cursors.Default
                Exit Sub
            End Try

            Dim nodes As System.Xml.XmlNodeList
            nodes = rssDoc.SelectNodes("/rss/channel")

    Thursday, November 13, 2008 8:11 PM

All replies

  • Hi,


    here are some links that will help. There is a lot of information available on the internet about RSS / ATOM and what your looking to do.

     

    http://www.mnot.net/rss/tutorial/

     

    http://www.devarticles.com/c/a/Delphi-Kylix/Creating-an-RSS-Reader/

    http://www.cstruter.com/articles/replyarticle.aspx?ContentID=121

    http://www.dreamincode.net/forums/showtopic34745.htm

    Thursday, November 13, 2008 4:33 PM
  • Here is some code that will load an RSS feed off the internet into a XML nodes list.
            Try
                Dim rssUrl = FeedTB.Text
                Dim rssRequest As System.Net.WebRequest = System.Net.WebRequest.Create(rssUrl)
                Dim rssResponse As System.Net.WebResponse = rssRequest.GetResponse()
                Dim rssStream = rssResponse.GetResponseStream()
            Catch ex As Net.WebException
                MsgBox("URL not found.", MsgBoxStyle.Critical, "RSS Tick")
                Exit Sub
            End Try

            Dim rssDoc As New System.Xml.XmlDocument
            Try
                rssDoc.Load(rssStream)
            Catch ex As Xml.XmlException
                MsgBox("URL not a valid RSS document.", MsgBoxStyle.Critical, "RSS Tick")
                Cursor = Cursors.Default
                Exit Sub
            End Try

            Dim nodes As System.Xml.XmlNodeList
            nodes = rssDoc.SelectNodes("/rss/channel")

    Thursday, November 13, 2008 8:11 PM
  • Hi again,

     

    You can also use XSLT to transform the RSS feed into HTML.......

     

            Dim html As New StringBuilder()

            Dim stringStream As New StringWriter(html)

     

            Dim rss As XmlReader = XmlReader.Create("http://www.rss.com/feed.xml")

            Dim xslt As New XslCompiledTransform()

            xslt.Load("RSSFeedXSLT.xslt")

            xslt.Transform(rss, Nothing, stringStream)

     

            Me.WebBrowser1.DocumentText = html.ToString()

     

    and saving the following XSLT stylesheet to RSSFeedXSLT.xslt.... obviously this isn't a particular grand stylesheet but you have the idea.

     

    Code Snippet

    <?xml version="1.0" encoding="UTF-8"?>

    <xsl:stylesheet version="1.0"

      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

     

      <xsl:output method="html"/>

     

      <xsl:template match="/">

        <html>

          <head>

            <title>

              <xsl:value-of select="/rss/channel/title"/>

            </title>

            <link rel="stylesheet" href="digg.css" type="text/css"/>

          </head>

          <body>

            <xsl:apply-templates select="rss/channel"/>

          </body>

        </html>

      </xsl:template>

     

      <xsl:template match="channel">

        <body>

          <div class="topbox">

            <p>

              This is a <strong>RSS-feed</strong> from the <xsl:value-of select="title"/>

              website. RSS feeds allow you to stay up to date with the latest news and

              features you want from  <xsl:value-of select="title"/>. To subscribe to it,

              you will need a News Reader or other similar device.

            </p>

          </div>

          <div class="contbox">

            <div class="mainbox">

              <div class="itembox">

                <ul>

                  <xsl:apply-templates select="item"></xsl:apply-templates>

                </ul>

              </div>

            </div>

          </div>

        </body>

      </xsl:template>

     

      <xsl:template match="item">

        <li>

          <a href="{link}">

            <xsl:value-of select="title"/>

          </a>

          <small>

            &#8212; <xsl:value-of select="pubDate"/>

          </small>

          <br/>

          <div class="item_desc">

            <xsl:value-of disable-output-escaping="yes" select="description"/>

          </div>

        </li>

      </xsl:template>

    </xsl:stylesheet>

     

     

     

     

    Thursday, November 13, 2008 11:50 PM