【问题标题】:Publish to RSS from command line从命令行发布到 RSS
【发布时间】:2009-02-12 16:44:05
【问题描述】:

我希望能够从 Windows 命令行发布到 RSS 提要。我想象这样的事情:

rsspub @builds "Build completed without errors."

然后,有人可以访问我的电脑:

http://xp64-Matt:9090/builds/rss.xml

并且会有一个新条目,其中包含日期和时间以及简单的文本“构建完成且没有错误。”

我希望提要本身在不同的端口上运行,因此我不会与 IIS 或 Apache 或其他任何我需要在我的计算机上日常运行的东西打架。

这样的事情存在吗?

【问题讨论】:

    标签: rss development-environment build-environment


    【解决方案1】:

    这是一个简单的 .Net 3.5 C# 程序,它将创建一个 RSS XML 文件,您可以将其存储在 IIS webroot 中:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Xml;
    using System.IO;
    
    namespace CommandLineRSS
    {
        class Program
        {
            static void Main( string[] args )
            {
                var file = args[ 0 ];
                var newEntry = args[ 1 ];
    
                var xml = new XmlDocument();
    
                if ( File.Exists( file ) )
                    xml.Load( file );
                else
                    xml.LoadXml( @"<rss version='2.0'><channel /></rss>" );
    
                var xmlNewEntry = Create( (XmlElement)xml.SelectSingleNode( "/rss/channel" ), "item" );
                Create( xmlNewEntry, "title" ).InnerText = newEntry;
                Create( xmlNewEntry, "pubDate" ).InnerText = DateTime.Now.ToString("R");
    
                xml.Save( file );
            }
    
            private static XmlElement Create( XmlElement parent, string tag )
            {
                var a = parent.OwnerDocument.CreateElement( tag );
                parent.AppendChild( a );
                return a;
            }
        }
    }
    

    那么你可以这样称呼它:

    CommandLineRSS.exe c:\inetpub\wwwroot\builds.xml "Build completed with errors."
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-26
      • 1970-01-01
      相关资源
      最近更新 更多