|
||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionThis article is aimed at explaining how the The application created here has the following features:
BackgroundThe application in this article has been developed using Visual Studio 2008, but in .NET Framework 2.0. It can be built and run as is using .NET Framework 3.0 and 3.5. Using the CodeThe code in this article works using Now, coming to the Since RSS feeds are XML, we need to use XML objects to process it. For this, we need to import the namespace using System.Xml;
Then we need to create an XML document and load up the RSS content into it: XmlDocument RSSXml = new XmlDocument();
RSSXml.Load(txtURL.Text);
Then we need to get the list of nodes from this XML document, that can be used to display the feed content. After that, we go through each node and pull out display relevant information from it, like the title, link and description. XmlNodeList RSSNodeList = RSSXml.SelectNodes("rss/channel/item");
StringBuilder sb = new StringBuilder();
foreach (XmlNode RSSNode in RSSNodeList)
{
XmlNode RSSSubNode;
RSSSubNode = RSSNode.SelectSingleNode("title");
string title = RSSSubNode != null ? RSSSubNode.InnerText : "";
RSSSubNode = RSSNode.SelectSingleNode("link");
string link = RSSSubNode != null ? RSSSubNode.InnerText : "";
RSSSubNode = RSSNode.SelectSingleNode("description");
string desc = RSSSubNode != null ? RSSSubNode.InnerText : "";
sb.Append("<font face='arial'><p><b><a href='");
sb.Append(link);
sb.Append("'>");
sb.Append(title);
sb.Append("</a></b><br/>");
sb.Append(desc);
sb.Append("</p></font>");
}
At the end of this, the string builder contains the content of RSS feed, as a well formatted HTML. This is where we start off with the RSSBrowser.DocumentText = sb.ToString();
Now we need to learn how to communicate between two browser controls. By default, if a link is clicked on a page loaded in a To do this, we need to understand the private void RSSList_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
if (!m_bFromLoadEvent)
{
e.Cancel = true;
NetBrowser.Navigate(e.Url);
}
else
{
m_bFromLoadEvent = false;
}
}
This code, based on a boolean value, blocks the current object's navigation and navigates another Lastly, we need to learn how to navigate back and forth between the pages already visited by the if (NetBrowser.CanGoBack)
{
NetBrowser.GoBack();
}
if (NetBrowser.CanGoForward)
{
NetBrowser.GoForward();
}
The Points of InterestThe application stores the list of subscribed RSS feeds in a text file in the same location as the program EXE. Coming soon in the next versions of History
|
|||||||||||||||||||||||||||||||||||||||||||||||