开发者

How do I filter an rss feed using a regular expression on its contents?

How do I filter an rss feed?

  • I'm using windows
  • The RSS feed is on an internal network (so I can't use external websites).
  • The RSS reader I'd like to use is Outlook (again because of the internal network).
  • I'm open to hearing about .net solutions.
  • 开发者_开发百科


I'm building an program in C#. Something like this:

string originalFeedUrl = args[ 0 ];
string regex = args[ 1 ];
XmlDocument doc = new XmlDocument();
doc.Load( originalFeedUrl );

XmlNodeList descriptions = doc.SelectNodes( @"//item/description" );
foreach( XmlNode description in descriptions ) {
    if( !Regex.IsMatch( description.InnerText, regex ) )
        description.ParentNode.ParentNode.RemoveChild(description.ParentNode );
}

Console.WriteLine(doc.OuterXml);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜