开发者

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

开发者 https://www.devze.com 2023-02-17 23:36 出处:网络
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).

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

精彩评论

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

关注公众号