Self updating rss feed with xml
LINQ to XML provides a clean programming model that enables you to read, construct and write XML data.
To get a sense of how LINQ to XML works, we can create a simple XML file on our local file-system like below that uses a custom schema we've defined to store RSS feeds: I could then use the new XDocument class within the System. Linq namespace to open and query the XML document above.
You can learn more about them in my previous New "Orcas" Language Feature: Anonymous Types blog post.
While anonymous types can be super useful when you want to locally iterate and work with data, we'll often want/need to define a standard class when passing the results of our LINQ query between multiple classes, across class library assemblies, and over web-services.
30 December 2017, pm Iran protesters voice opposition in Iranian cities Demonstrations that began in one city on Thursday have now spread to several major cities in Iran.
For an example of this in action, let's take a look at the XML of my blog's RSS feed ( I could write the LINQ to XML code below to retrieve the above blog post data from my RSS feed, and work with the individual feed items as .
NET objects: Note above how I am converting the "Published" field in the RSS field - which is a string in the XML - to a . Notice also how LINQ to XML includes a built-in XNamespace type that provides a type-safe way to declare and work with XML Namespaces (which I need to-do to retrieve the element).
With this change I'm now returning a sequence of Feed Definition objects that I can pass from class to class, assembly to assembly, and across web-services. Load(path) static method supports the ability open both XML files from the file-system, as well as remote XML feeds returned from an HTTP URL.
This enables you to use it to access remote RSS feeds, REST APIs, as well as any other XML feed published on the web.