Click here to Skip to main content
6,635,160 members and growing! (16,771 online)
Email Password   helpLost your password?
General Programming » Macros and Add-ins » VS.NET Macros     Intermediate

Visual Studio .NET RSS Viewer with XSL

By Corneliu Tusnea

Another macro to show an RSS feed in VS.NET, nicely formatted using the CP colors
C#, VC6, VC7, VC7.1, .NET, Win2K, WinXP, Win2003, Visual Studio, Dev
Posted:9 Mar 2004
Views:38,914
Bookmarked:15 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
4 votes for this article.
Popularity: 2.66 Rating: 4.42 out of 5

1

2

3
2 votes, 50.0%
4
2 votes, 50.0%
5

Introduction

RSS feeds are more and more popular and as any site that respects itself, CodeProject also provides a nice RSS feed with information about the latest articles.

As Steven Hicks just noticed in the Lounge http://www.codeproject.com/lounge.asp#xx761109xx CodeProject RSS link is not so easy to notice. If you are a real CPA (CodeProjectAdict) you do want to see "What's new on CP" at any moment. And the best place to see it is of course in you VS.Net environment where you spend most of you time anyway. Plus that you don't have to open a new explorer window just to see if there is anything new on CP.

And if you could also see the latest news in the CodeProject style (colors, fonts) it would be even nicer.

Sample screenshot

XSL

Thus, to achive this goal I made a small XSL file to translate the RSS from CP to a nice formated HTML webpage that gets displayed inside VS.Net but a simple mouse click.

Macro

The macro is based 99% on the one provided by Davy Mitchell in his article Visual Studio .NET RSS Headline Viewer.

    Function GetHTML(ByVal strPage As String) As String

        If strPage.StartsWith("http://") Then
            Try
                Dim oReq As System.Net.HttpWebRequest
                Dim oResp As System.Net.HttpWebResponse
                oReq = System.Net.HttpWebRequest.Create(strPage)
                oResp = oReq.GetResponse
                Dim sr As New StreamReader(oResp.GetResponseStream)
                Return sr.ReadToEnd()
            Catch
                'Do something with your error        

            End Try
        Else    ' local file ?

            Dim sr As StreamReader = New StreamReader(strPage)
            Return sr.ReadToEnd()
        End If

    End Function


    Public Sub RefreshRSS()
        Try
            'DESCRIPTION: Grabs headlines and displays them as text.

            Dim RDFText As String
            Dim objTextDoc As TextDocument
            Dim objEP As EditPoint

            'Create a new text document.

            Call DTE.ItemOperations.NewFile("General\Text File")

            'Get a handle to the new document.

            objTextDoc = DTE.ActiveDocument.Object("TextDocument")
            objEP = objTextDoc.StartPoint.CreateEditPoint
            RDFText = GetHTML(http://www.codeproject.com/ & _ 
                  "webservices/articlerss.aspx?cat=3")

            objEP.Insert("<?xml-stylesheet type=""text/xsl"" " & _
                  "href=""change.xsl""?>" + vbCrLf)

            RDFText = RDFText.Replace("�", "(c)")

            objEP.Insert(RDFText)

            'Store

            ActiveDocument.Save("C:\\temp\\news.xml")
            ActiveDocument.Close()

            Dim ItemOp As ItemOperations
            ItemOp = DTE.ItemOperations
            ItemOp.Navigate("file://C:\temp\news.xml", _
                  vsNavigateOptions.vsNavigateOptionsDefault)

        Catch err As System.Exception
            MsgBox(err.ToString)
        End Try
    End Sub

Usage

  • Unzip the files to a folder of your choice (C:\temp) for example.
  • Drop this macro in your macro editor, assign the macro to a button and update the paths in the macro with the path where you unziped the files.
  • Click the button :).

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Corneliu Tusnea


Member
8 years commercial experience out of which 7 years developing financial applications for different stock exchanges.
5 years VC++ and about 2.5 years C# experience and a bit of Java.

Now working with the fantastic guys from Readify, a group of elite consultants specialising in technical readiness.

Keeping a blog at:
www.acorns.com.au

Developing:
Hawkeye - The .Net Runtime Object Editor - A developer's best tool.

Keeping myself busy with my site:
www.bestgames.com.au website.
Occupation: Web Developer
Location: Australia Australia

Other popular Macros and Add-ins articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 4 of 4 (Total in Forum: 4) (Refresh)FirstPrevNext
GeneralProblems with special characters PinmemberLpalma17:28 10 Jun '05  
Generalbetter... PinsussAnonymous20:05 16 Mar '04  
GeneralRe: better... Pinmemberrkiesler7:18 17 Mar '04  
General[Message Removed] Pinmemberimmetoz10:45 1 Oct '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 9 Mar 2004
Editor: Nishant Sivakumar
Copyright 2004 by Corneliu Tusnea
Everything else Copyright © CodeProject, 1999-2009
Web21 | Advertise on the Code Project