顯示具有 RSS 標籤的文章。 顯示所有文章
顯示具有 RSS 標籤的文章。 顯示所有文章

2023年2月4日 星期六

[研究]QuiteRSS 0.19.4 RSS Reader 閱讀器

[研究]QuiteRSS 0.19.4 RSS Reader 閱讀器

2023-02-04

臨時需要RSS Reader,以前的官方網站倒了,另外尋址和測試可用於 Windows的,找到這套。

官方網站,0.19.4版本於 21.04.2020 09:27 釋出
https://quiterss.org/

確認可用。

(完)

相關

QuiteRSS 0.19.4 免安裝中文版 - 取代Google Reader的RSS閱讀器 免費可攜自由軟體(2021-01-05)\QuiteRSSPortable
https://www.azofreeware.com/2013/08/quiterss-0132-google-readerrss.html

2022年12月24日 星期六

[研究][ASP.NET][RSS]XML declaration allowed only at the start of the document

[研究][ASP.NET]error on line 3 at column 6: XML declaration allowed only at the start of the document

2022-12-23

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C#

********************************************************************************

This page contains the following errors:

error on line 3 at column 6: XML declaration allowed only at the start of the document

Below is a rendering of the page up to the first error.

********************************************************************************

檢查

XML declaration allowed only at the start of the document => XML 聲明只允許在文檔的開頭

Default.aspx

<%@ Page Language="C#" ContentType="text/xml" AutoEventWireup="false" CodeBehind="RSS.aspx.cs" Inherits="NICSFrontWebApplication.RSS" %>
<?xml version="1.0" encoding="utf-8" ?>

檢視網頁 HTML Source,發現第一行是空的,Page 那行必須刪除。

(完)

相關

[研究][ASP.NET]RSS (用 XmlDocument)

[研究][ASP.NET]RSS (用 XmlDocument)

2022-12-23
2023-01-06 更新,日期改用 ISO 8601

RSS(英文全稱:RDF Site Summary 或 Really Simple Syndication),中文譯作簡易資訊聚合,也稱聚合內容,是一種訊息來源格式規範,用以聚合多個網站更新的內容並自動通知網站訂閱者。使用 RSS 後,網站訂閱者便無需再手動檢視網站是否有新的內容,同時 RSS 可將多個網站更新的內容進行整合,以摘要的形式呈現,有助於訂閱者快速獲取重要資訊,並選擇性地點閱檢視。

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C#

********************************************************************************

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" 
    Inherits="WebApplication1.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <a href="myfeed.xml">myfeed.xml</a>
        </div>
    </form>
</body>
</html>


Default.aspx.cs

using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;

namespace NICSFrontWebApplication
{
    public partial class RSSService : BaseWebPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            RSS1(sender, e);
        }

        #region == 新聞 RSS  ==
        protected void RSS1(object sender, EventArgs e)
        {
            try
            {
                // Create the XmlDocument.
                XmlDocument doc = new XmlDocument();

                // rss 加到
                XmlElement rss = doc.CreateElement("rss");
                rss.SetAttribute("version", "2.0");
                doc.AppendChild(rss);

                // channel 加到 rss 下
                XmlElement channel = doc.CreateElement("channel");
                rss.AppendChild(channel);

                XmlElement channelTitle = doc.CreateElement("title");
                channelTitle.InnerText = "新聞";
                channel.AppendChild(channelTitle);

                XmlElement channelLink = doc.CreateElement("link");
                channelLink.InnerText = "https://www.myWebSite.tw/";
                channel.AppendChild(channelLink);

                XmlElement channelDesc = doc.CreateElement("description");
                channelDesc.InnerText = "";
                channel.AppendChild(channelDesc);

                //string xPathExpression = "/rss/channel/item";
                //XmlNodeList nodelist = doc.SelectNodes(xPathExpression);

                //doc.LoadXml("<item><name>wrench</name></item>");
                //doc.LoadXml("<item></item>");
                //doc.LoadXml("<rss version=\"2.0\"><channel><title>新聞</title><link>https://www.myWebSite.tw/</link>");
                //doc.LoadXml("<item><name>wrench</name></item>");
                //doc.LoadXml("</channel></rss>");

                //XmlElement newElem = doc.CreateElement("rss");
                //newElem.SetAttribute("version", "2.0");
                //newElem.InnerText = "";
                //doc.DocumentElement.AppendChild(newElem);

                // Add a price element.
                //XmlElement newElem = doc.CreateElement("price");
                //newElem.InnerText = "10.95";
                //doc.DocumentElement.AppendChild(newElem);

                string queryString = @"SELECT 
[seq]
 ,rssTitle
  ,rssDesc
   ,CONVERT(NVARCHAR(30), rssDate, 126)
FROM [MyTable] "; using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["NICSDBConnectionString"].ConnectionString)) { SqlCommand command = new SqlCommand(queryString, connection); connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { string seq = reader["seq"].ToString(); string rssTitle = reader["rssTitle"].ToString(); string rssDesc = reader["rssDesc"].ToString(); string rssDate = reader["rssDate"].ToString(); XmlElement item = doc.CreateElement("item"); channel.AppendChild(item); XmlElement linkElem = doc.CreateElement("link"); linkElem.InnerText = "https://www.myWebSite.tw/News.aspx?seq=" + seq; item.AppendChild(linkElem); XmlElement authorElem = doc.CreateElement("author"); authorElem.InnerText = "webmaster@myWebSite.tw"; item.AppendChild(authorElem); XmlElement titleElem = doc.CreateElement("title"); titleElem.InnerText = rssTitle; item.AppendChild(titleElem); XmlElement descElem = doc.CreateElement("description"); descElem.InnerText = rssDesc; item.AppendChild(descElem); XmlElement dateElem = doc.CreateElement("pubDate"); dateElem.InnerText = rssDate; item.AppendChild(dateElem); } } } XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; // Save the document to a file and auto-indent the output. XmlWriter writer = XmlWriter.Create(Server.MapPath(".") + "\\myfeed.xml", settings); doc.Save(writer); } catch (Exception) { //throw; } } #endregion == 新聞 RSS == } } }



(完)

相關

RSS - 維基百科,自由的百科全書
https://zh.m.wikipedia.org/zh-tw/RSS

System.ServiceModel.Syndication 命名空間
https://learn.microsoft.com/zh-tw/dotnet/api/system.servicemodel.syndication?view=dotnet-plat-ext-7.0

Rss20FeedFormatter 類別 (System.ServiceModel.Syndication) | Microsoft Learn
https://learn.microsoft.com/zh-tw/dotnet/api/system.servicemodel.syndication.rss20feedformatter?view=dotnet-plat-ext-7.0

[研究]SQL Server 2019 T-SQL 取得 ISO 8601標準之日期時間
http://shaurong.blogspot.com/2023/01/sql-server-2019-t-sql-iso-8601.html


[研究][ASP.NET]RSS (用 FileStream 和 StreamWriter)

[研究][ASP.NET]RSS (用 FileStream 和 StreamWriter)

2022-12-23

RSS(英文全稱:RDF Site Summary 或 Really Simple Syndication),中文譯作簡易資訊聚合,也稱聚合內容,是一種訊息來源格式規範,用以聚合多個網站更新的內容並自動通知網站訂閱者。使用 RSS 後,網站訂閱者便無需再手動檢視網站是否有新的內容,同時 RSS 可將多個網站更新的內容進行整合,以摘要的形式呈現,有助於訂閱者快速獲取重要資訊,並選擇性地點閱檢視。

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C#

********************************************************************************

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" 
    Inherits="WebApplication1.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <a href="myfeed.xml">myfeed.xml</a>
        </div>
    </form>
</body>
</html>


Default.aspx.cs

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            FileStream fs = null;
            StreamWriter sw = null;

            try
            {
                fs = new FileStream(Server.MapPath(".") + "\\myfeed.xml", System.IO.FileMode.Create,

                System.IO.FileAccess.Write);
                sw = new StreamWriter(fs);

                // Write header of RSS file.
                sw.WriteLine("<?xml version=\"1.0\"?>");
                sw.WriteLine("<rss version=\"2.0\" xml:base=\"http://www.myWebSite.com\">");
                sw.WriteLine("<channel>");
                sw.WriteLine("<title>My RSS Feed Title</title>");
                sw.WriteLine("<link>http://www.myWebsite.com</link>");
                sw.WriteLine("<description>My feed description</description>");
                sw.WriteLine("<language>en-us</language>");
                sw.WriteLine("<image>");
                sw.WriteLine("<title>My Title</title>");

                sw.WriteLine("<url>http://www.myWebsite.com/image.gif</url>");
                sw.WriteLine("<link>http://www.myWebsite.com</link>");
                sw.WriteLine("<width>50</width>");
                sw.WriteLine("<height>60</height>");
                sw.WriteLine("</image>");
                // Done adding header of RSS file.

                // Begin adding items (article content).
                sw.WriteLine("<item>");
                sw.WriteLine("<title>Title of article</title>");
                sw.WriteLine("<link>http://www.myWebsite.com/page1.html</link>");
                sw.WriteLine("<description><![CDATA[Body of content goes here.<BR>HTML text can be included inside this tag.<BR>]]></description>");
                sw.WriteLine("<pubDate>" + System.DateTime.Now.ToString("r") + "</pubDate>");
                sw.WriteLine("</item>");
                // End adding item (you can continue adding items here).

                // Write footer of RSS feed.
                sw.WriteLine("</channel>");
                sw.WriteLine("</rss>");
            }
            catch (Exception exp)
            {
                //Debug.WriteLine("Error: " + exception.Message);
            }
            finally
            {
                sw.Close();
                fs.Close();
            }
        }
    }
}




敝人測試,這種作法有個缺點,輸入的文字是靜態確認的,如果參雜了不確定內容的字串變數,會出錯。(例如從資料庫抓出的資料)(有點怪,待研究)

(完)

相關

RSS - 維基百科,自由的百科全書
https://zh.m.wikipedia.org/zh-tw/RSS

System.ServiceModel.Syndication 命名空間
https://learn.microsoft.com/zh-tw/dotnet/api/system.servicemodel.syndication?view=dotnet-plat-ext-7.0

Rss20FeedFormatter 類別 (System.ServiceModel.Syndication) | Microsoft Learn
https://learn.microsoft.com/zh-tw/dotnet/api/system.servicemodel.syndication.rss20feedformatter?view=dotnet-plat-ext-7.0