I use VS2010, C# I want to read RSS content from other sites and display them in my site, currently this process is performed manually (site admin searches other sites and copy/pastes related content in news items!), but I want to do it automatically and I think the best solution is RSS, I've tried several sample codes but none of them worked, is there an easy way to implement RSS reader in ASP.NET? what are my options here?
Asked
Active
Viewed 1,578 times
0
-
2have you looked at this http://stackoverflow.com/questions/576267/c-sharp-rss-reader – Ray Cheng May 20 '12 at 07:48
1 Answers
1
Read RSS Link
public void ReadDoc(XmlDocument rssDoc)
{
XmlNode nodeRss = null;
XmlNode nodeChannel = null;
XmlNode nodeItem = null;
try
{
if (rssDoc == null)
{
return;
}
// Loop for the <rss> tag
for (int i = 0; i < rssDoc.ChildNodes.Count; i++)
{
// If it is the rss tag
if (rssDoc.ChildNodes[i].Name == "rss")
{
nodeRss = rssDoc.ChildNodes[i];
break;
}
}
if (nodeRss == null)
{
return;
}
for (int i = 0; i < nodeRss.ChildNodes.Count; i++)
{
if (nodeRss.ChildNodes[i].Name == "channel")
{
nodeChannel = nodeRss.ChildNodes[i];
break;
}
}
if (nodeChannel == null)
{
return;
}
// Loop for the <title>, <link>, <description> and all the other tags
for (int i = 0; i < nodeChannel.ChildNodes.Count; i++)
{
if (nodeChannel.ChildNodes[i].Name == "item")
{
nodeItem = nodeChannel.ChildNodes[i];
if (nodeItem["title"] != null){}
if (nodeItem["description"] != null){}
if (nodeItem["pubDate"] != null){}
}
}
}
catch (Exception)
{
throw;
}
finally
{
nodeRss = null;
nodeChannel = null;
nodeItem = null;
}
}
public void CreateRSS(String Path)
{
XmlDocument doc = null;
XmlTextReader rssReader = null;
Label doclbl = null;
Label snolbl = null;
try
{
try
{
rssReader = new XmlTextReader(Path);
}
catch (Exception)
{
return;
}
if (rssReader == null)
{
return;
}
doc = new XmlDocument();
try
{
doc.Load(rssReader);
}
catch (Exception)
{
return;
}
if (doc == null)
{
return;
}
ReadDoc(doc);
}
catch (Exception)
{
throw;
}
finally
{
doc = null;
rssReader = null;
doclbl = null;
snolbl = null;
}
}

Nilish
- 1,066
- 3
- 12
- 26
-
Apparently you do not understand what this code do, and what the question ask. – Aristos May 20 '12 at 09:08