从命令行发布到RSS

时间:2023-01-24 12:19:16

From a Windows command line, I'd like to be able to publish to an RSS feed. I visualize something like this:

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

rsspub @builds "Build completed without errors."

Then, someone could go to my computer:

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

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

And there'd be a new entry with the date and time and the simple text "Build completed without errors."

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

I'd like the feed itself to run on a different port, so I'm not fighting with IIS or Apache, or whatever else I need to run on my computer on a day-to-day basis.

我希望feed本身可以在不同的端口上运行,所以我不会与IIS或Apache,或者我需要在日常运行的计算机上运行其他任何东西。

Does anything like this exist?

有这样的事吗?

1 个解决方案

#1


Here's a simple .Net 3.5 C# program that will create an RSS XML file that you can store in your IIS webroot:

这是一个简单的.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;
        }
    }
}

Then you can call it like this:

然后你可以像这样调用它:

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

#1


Here's a simple .Net 3.5 C# program that will create an RSS XML file that you can store in your IIS webroot:

这是一个简单的.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;
        }
    }
}

Then you can call it like this:

然后你可以像这样调用它:

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