Display RSS Feeds in Your Website & If Needed How to Store Them in DataBase
RSS Feeds comes in the XML format and we all know that there is a start tag and other are child tag of start tag in XML format. You can read more about RSS Feeds and It's format or For simply overview you can read it from here.
All the data comes in RSS Feeds like this-
All the data comes in RSS Feeds like this-
<rss version="2.0">
<channel>
-----
-----
<item>
---
---
</item>
</channel>
</rss>
to get the element inside RSS Feeds we will have to first select it's parent tag suppose..if we want title of any RSS then we will have to first select Channel tag the go to next step. like this..
XmlDocument doc = new XmlDocument();
XmlNodeList a = doc.SelectNodes("rss/channel/item");
as from the above code it is clear that we are going to do some thing with inside the <item></item> tag that's why we selected node with the help of XmlNodeList variable 'a'.
foreach (XmlNode rssNode in a)
{
XmlNode 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 description = rssSubNode != null ? rssSubNode.InnerText : "";
{
XmlNode 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 description = rssSubNode != null ? rssSubNode.InnerText : "";
}
To store this in Database simply make connection and fire Sql Query with the help of variable string title, link and description. look at this snap shot in comment.
Rss Feeds in Asp.Net |
Comments
Post a Comment