### Create an RssItem Source: https://context7.com/jthelin/rss2schema/llms.txt Instantiates an RssItem with various elements including title, link, description, publication date, GUID, author, category, enclosure, and comments. Ensure at least one of title or description is present. ```csharp using rss2.schema; using System; using System.Globalization; var item = new RssItem { ItemsElementName = new[] { ItemsChoiceType1.title, ItemsChoiceType1.link, ItemsChoiceType1.description, ItemsChoiceType1.pubDate, ItemsChoiceType1.guid, ItemsChoiceType1.author, ItemsChoiceType1.category, ItemsChoiceType1.enclosure, ItemsChoiceType1.comments }, Items = new object[] { "Hello World", "https://example.com/blog/hello-world", "My first blog post about <strong>XML schemas</strong>.", new DateTime(2024, 1, 1, 9, 0, 0, DateTimeKind.Utc) .ToString(DateTimeFormatInfo.InvariantInfo.RFC1123Pattern, CultureInfo.GetCultureInfo("en-US")), new Guid { isPermaLink = true, Value = "https://example.com/blog/hello-world" }, "editor@example.com", new Category { Value = "Technology", domain = "https://example.com/categories" }, new Enclosure { url = "https://example.com/audio/ep1.mp3", length = "12345678", type = "audio/mpeg" }, "https://example.com/blog/hello-world#comments" } }; ``` -------------------------------- ### Create a Guid object Source: https://context7.com/jthelin/rss2schema/llms.txt Instantiates a Guid object for unique item identification. Set 'isPermaLink' to true if the 'Value' is a URL, otherwise set to false for opaque identifiers. ```csharp // Permalink GUID (default — value must be a URL) var permalinkGuid = new Guid { isPermaLink = true, Value = "https://example.com/blog/hello-world" }; // Opaque tag URI GUID (not a permalink) var tagGuid = new Guid { isPermaLink = false, Value = "tag:example.com,2024:/blog/42" }; ``` -------------------------------- ### Guid Class Source: https://context7.com/jthelin/rss2schema/llms.txt Provides a unique identifier for an item. If `isPermaLink` is true, the value must be a valid URL. If false, it's an opaque unique string. ```APIDOC ## `Guid` Class — Unique item identifier `Guid` provides a unique identifier for an item. When `isPermaLink` is `true` (default), the value must be a valid URL that points to the item; when `false`, it is an opaque unique string (e.g., a tag URI). ```csharp // Permalink GUID (default — value must be a URL) var permalinkGuid = new Guid { isPermaLink = true, Value = "https://example.com/blog/hello-world" }; // Opaque tag URI GUID (not a permalink) var tagGuid = new Guid { isPermaLink = false, Value = "tag:example.com,2024:/blog/42" }; ``` ``` -------------------------------- ### RssItem Class Source: https://context7.com/jthelin/rss2schema/llms.txt Represents a single `` in an RSS feed. It supports flexible ordering of elements like title, link, description, publication date, GUID, author, category, enclosure, and comments. ```APIDOC ## `RssItem` Class — Individual feed entry `RssItem` represents a single `` in the channel. Like `RssChannel`, it uses parallel `Items` / `ItemsElementName` arrays to support flexible element ordering. At least one of `title` or `description` should be present per the RSS specification. ```csharp using rss2.schema; using System; using System.Globalization; var item = new RssItem { ItemsElementName = new[] { ItemsChoiceType1.title, ItemsChoiceType1.link, ItemsChoiceType1.description, ItemsChoiceType1.pubDate, ItemsChoiceType1.guid, ItemsChoiceType1.author, ItemsChoiceType1.category, ItemsChoiceType1.enclosure, ItemsChoiceType1.comments }, Items = new object[] { "Hello World", "https://example.com/blog/hello-world", "My first blog post about <strong>XML schemas</strong>.", new DateTime(2024, 1, 1, 9, 0, 0, DateTimeKind.Utc) .ToString(DateTimeFormatInfo.InvariantInfo.RFC1123Pattern, CultureInfo.GetCultureInfo("en-US")), new Guid { isPermaLink = true, Value = "https://example.com/blog/hello-world" }, "editor@example.com", new Category { Value = "Technology", domain = "https://example.com/categories" }, new Enclosure { url = "https://example.com/audio/ep1.mp3", length = "12345678", type = "audio/mpeg" }, "https://example.com/blog/hello-world#comments" } }; ``` ``` -------------------------------- ### Create an Enclosure object Source: https://context7.com/jthelin/rss2schema/llms.txt Instantiates an Enclosure object for media attachments. All attributes 'url', 'length' (file size in bytes), and 'type' (MIME type) are required. ```csharp // Podcast episode enclosure var enclosure = new Enclosure { url = "https://example.com/podcasts/episode-42.mp3", length = "24986756", // file size in bytes (non-negative integer) type = "audio/mpeg" // MIME type }; // Video enclosure var videoEnclosure = new Enclosure { url = "https://example.com/videos/demo.mp4", length = "104857600", type = "video/mp4" }; ``` -------------------------------- ### Create and Serialize RSS Feed Object in C# Source: https://context7.com/jthelin/rss2schema/llms.txt Demonstrates creating a root 'rss' object and serializing it to XML using System.Xml.Serialization. The 'version' defaults to '2.0'. ```csharp using rss2.schema; using System.Xml.Serialization; var feed = new rss(); // version defaults to 2.0 var channel = new RssChannel(); feed.channel = channel; // Serialize to XML var serializer = new XmlSerializer(typeof(rss)); serializer.Serialize(Console.Out, feed); ``` -------------------------------- ### Create an Image object Source: https://context7.com/jthelin/rss2schema/llms.txt Instantiates an Image object for a channel's logo. The 'url', 'title', and 'link' are essential. 'width' and 'height' have constraints (max 144 and 400 pixels respectively). ```csharp var image = new Image { url = "https://example.com/images/logo.png", title = "Example Blog", // used as HTML link = "https://example.com", width = "120", // pixels, max 144 height = "60", // pixels, max 400 description = "Example Blog Logo" // used in HTML }; ``` -------------------------------- ### Create SkipHoursList and SkipDaysList objects Source: https://context7.com/jthelin/rss2schema/llms.txt Instantiates SkipHoursList or SkipDaysList to provide cache hints to aggregators. SkipHours specifies GMT hours to avoid, and SkipDays specifies days of the week. ```csharp // Skip fetching during overnight hours (midnight–6 AM UTC) var skipHours = new SkipHoursList { hour = new[] { "0", "1", "2", "3", "4", "5", "6" } }; // Skip fetching on weekends var skipDays = new SkipDaysList { day = new[] { SkipDay.Saturday, SkipDay.Sunday } }; ``` -------------------------------- ### Generate C# Classes from XSD Source: https://context7.com/jthelin/rss2schema/llms.txt Use the xsd.exe tool with the provided xsdcodegen.cmd script to generate C# classes from the rss-2_0.xsd schema. Specify the output language and namespace. ```bat REM From the schema\ directory: xsd rss-2_0.xsd /classes /language:CS /namespace:rss2.schema REM Produces: rss-2_0.cs ``` -------------------------------- ### Populate RssChannel with Metadata and Items in C# Source: https://context7.com/jthelin/rss2schema/llms.txt This C# snippet shows how to populate an RssChannel object with required and optional metadata, including setting up the ItemsElementName and Items arrays for serialization. ```csharp using rss2.schema; using System.Globalization; var channel = new RssChannel(); // Required channel fields + optional metadata channel.ItemsElementName = new[] { ItemsChoiceType.title, ItemsChoiceType.link, ItemsChoiceType.description, ItemsChoiceType.language, ItemsChoiceType.copyright, ItemsChoiceType.managingEditor, ItemsChoiceType.ttl, ItemsChoiceType.image }; channel.Items = new object[] { "My Tech Blog", "https://example.com/blog", "Latest articles from My Tech Blog", "en-US", "Copyright 2024 Example Corp", "editor@example.com", "60", // cache TTL in minutes new Image { url = "https://example.com/logo.png", title = "My Tech Blog", link = "https://example.com/blog", width = "144", // max 144px height = "400" // max 400px } }; ``` -------------------------------- ### Create a Cloud object Source: https://context7.com/jthelin/rss2schema/llms.txt Instantiates a Cloud object to register a web service endpoint for RSS update notifications. Specify the 'domain', 'port', 'path', 'registerProcedure', and 'protocol' (xml-rpc, http-post, or soap). ```csharp var cloud = new Cloud { domain = "rpc.example.com", port = "80", path = "/RPC2", registerProcedure = "myCloud.rssPleaseNotify", protocol = CloudProtocol.xmlrpc // xml-rpc | http-post | soap }; ``` -------------------------------- ### Create a Category object Source: https://context7.com/jthelin/rss2schema/llms.txt Instantiates a Category object for content categorization. The 'Value' is the category name, and the optional 'domain' attribute specifies the taxonomy. ```csharp // Simple category var category = new Category { Value = "Technology" }; // Category with taxonomy domain var taggedCategory = new Category { Value = "open-source", domain = "https://example.com/tags" }; ``` -------------------------------- ### Construct and Serialize an RSS Feed Source: https://context7.com/jthelin/rss2schema/llms.txt Builds a full feed object graph and serializes it to XML using `XmlSerializer`. Requires referencing the `rss2.schema` library and using the `Items` / `ItemsElementName` pattern for feed construction. ```csharp using System; using System.Globalization; using System.Xml.Serialization; using rss2.schema; // Build feed var feed = new rss(); var channel = new RssChannel(); feed.channel = channel; // Channel metadata channel.ItemsElementName = new[] { ItemsChoiceType.title, ItemsChoiceType.link, ItemsChoiceType.description, ItemsChoiceType.language, ItemsChoiceType.skipDays }; channel.Items = new object[] { "Example Tech Blog", "https://example.com/blog", "Technology news and tutorials", "en-US", new SkipDaysList { day = new[] { SkipDay.Saturday, SkipDay.Sunday } } }; // Feed item var item = new RssItem { ItemsElementName = new[] { ItemsChoiceType1.title, ItemsChoiceType1.link, ItemsChoiceType1.description, ItemsChoiceType1.pubDate, ItemsChoiceType1.guid }, Items = new object[] { "Getting Started with XML Schemas", "https://example.com/blog/xml-schemas", "Learn how to validate XML documents using XSD schemas.", new DateTime(2024, 6, 15, 10, 0, 0, DateTimeKind.Utc) .ToString(DateTimeFormatInfo.InvariantInfo.RFC1123Pattern, CultureInfo.GetCultureInfo("en-US")), new Guid { isPermaLink = true, Value = "https://example.com/blog/xml-schemas" } } }; channel.item = new[] { item }; // Serialize to XML var serializer = new XmlSerializer(typeof(rss)); serializer.Serialize(Console.Out, feed); ``` -------------------------------- ### Cloud Class Source: https://context7.com/jthelin/rss2schema/llms.txt Registers a web service endpoint for lightweight pub-sub update notifications using supported protocols: xml-rpc, http-post, and soap. ```APIDOC ## `Cloud` Class — Publish-subscribe notifications `Cloud` registers a web service endpoint that supports the rssCloud interface for lightweight pub-sub update notifications. Supported protocols are `xml-rpc`, `http-post`, and `soap`. ```csharp var cloud = new Cloud { domain = "rpc.example.com", port = "80", path = "/RPC2", registerProcedure = "myCloud.rssPleaseNotify", protocol = CloudProtocol.xmlrpc // xml-rpc | http-post | soap }; ``` ``` -------------------------------- ### Create a Source Object Source: https://context7.com/jthelin/rss2schema/llms.txt Represents the RSS channel an item originally came from. The channel title is the element value, and the channel URL is the `url` attribute. ```csharp var source = new Source { url = "https://feeds.example.com/partner-blog.xml", Value = "Partner Blog" }; ``` -------------------------------- ### Enclosure Class Source: https://context7.com/jthelin/rss2schema/llms.txt Describes a media object (audio, video, image) attached to an item. The `url`, `length` (file size in bytes), and `type` (MIME type) attributes are all required. ```APIDOC ## `Enclosure` Class — Media attachment `Enclosure` describes a media object (audio, video, image) attached to an item. All three attributes (`url`, `length`, `type`) are required. ```csharp // Podcast episode enclosure var enclosure = new Enclosure { url = "https://example.com/podcasts/episode-42.mp3", length = "24986756", // file size in bytes (non-negative integer) type = "audio/mpeg" // MIME type }; // Video enclosure var videoEnclosure = new Enclosure { url = "https://example.com/videos/demo.mp4", length = "104857600", type = "video/mp4" }; ``` ``` -------------------------------- ### Validate RSS Feed using xmllint Source: https://context7.com/jthelin/rss2schema/llms.txt Use the xmllint command-line tool to validate an RSS 2.0 feed file against the rss-2_0.xsd schema. Ensure the schema file and feed file are in the correct paths. ```bash # Validate using xmllint (libxml2) xmllint --schema schema/rss-2_0.xsd my-feed.xml --noout # Expected output: my-feed.xml validates ``` -------------------------------- ### SkipHoursList / SkipDaysList Classes Source: https://context7.com/jthelin/rss2schema/llms.txt Provides hints to RSS aggregators about specific GMT hours or days of the week to skip fetching the feed, thereby reducing polling load. ```APIDOC ## `SkipHoursList` / `SkipDaysList` — Aggregator cache hints These types tell RSS aggregators which GMT hours (0–23) or days of the week they may skip fetching the feed, reducing unnecessary polling load. ```csharp // Skip fetching during overnight hours (midnight–6 AM UTC) var skipHours = new SkipHoursList { hour = new[] { "0", "1", "2", "3", "4", "5", "6" } }; // Skip fetching on weekends var skipDays = new SkipDaysList { day = new[] { SkipDay.Saturday, SkipDay.Sunday } }; ``` ``` -------------------------------- ### Category Class Source: https://context7.com/jthelin/rss2schema/llms.txt Assigns a channel or item to one or more categories. The optional `domain` attribute specifies the categorization taxonomy. ```APIDOC ## `Category` Class — Content categorization `Category` places a channel or item into one or more categories. The optional `domain` attribute identifies the categorization taxonomy. ```csharp // Simple category var category = new Category { Value = "Technology" }; // Category with taxonomy domain var taggedCategory = new Category { Value = "open-source", domain = "https://example.com/tags" }; ``` ``` -------------------------------- ### Validate RSS Feed using Java Source: https://context7.com/jthelin/rss2schema/llms.txt Validate an RSS 2.0 feed file using Java with Xerces or built-in JAXP. This command requires the xerces.jar to be in the classpath. ```bash # Validate using Java (Xerces / built-in JAXP) java -cp xerces.jar sax.Counter -v -s -f -p schema/rss-2_0.xsd my-feed.xml ``` -------------------------------- ### Image Class Source: https://context7.com/jthelin/rss2schema/llms.txt Defines the channel's associated logo image, including its URL, title, link, dimensions, and description. The schema constrains width to a maximum of 144 pixels and height to a maximum of 400 pixels. ```APIDOC ## `Image` Class — Channel image / logo `Image` specifies the channel's associated logo image. `width` defaults to `"88"` and `height` to `"31"`; the schema constrains width ≤ 144 and height ≤ 400. ```csharp var image = new Image { url = "https://example.com/images/logo.png", title = "Example Blog", // used as HTML link = "https://example.com", width = "120", // pixels, max 144 height = "60", // pixels, max 400 description = "Example Blog Logo" // used in HTML }; ``` ``` -------------------------------- ### Minimal Valid RSS 2.0 Feed XML Source: https://context7.com/jthelin/rss2schema/llms.txt This XML snippet represents a minimal, valid RSS 2.0 feed that conforms to the rss-2_0.xsd schema. It includes essential channel and item elements. ```xml My Tech Blog https://example.com/blog Latest articles from My Tech Blog en-US Mon, 01 Jan 2024 00:00:00 GMT Mon, 01 Jan 2024 12:00:00 GMT Hello World https://example.com/blog/hello-world My first blog post. https://example.com/blog/hello-world Mon, 01 Jan 2024 09:00:00 GMT editor@example.com Technology ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.