How to consume web log communication services information

Really Simple Discovery (RSD) provides a standard means for client software find the services needed to read, edit, or communicate with web logging software. The goal of RSD is to reduce the information required to set up editing software to three well known elements: user name, password, and the web site URL. Other critical data will either be defined in the related RSD endpoint, or discoverable using the information provided.

The classes that together compose the implementation of RSD are located in the Argotic.Syndication.Specialized namespace. The primary framework entity that you will use when working with RSD formated syndication resources is the RsdDocument class. This class implements the ISyndicationResource and IExtensibleSyndicationObject interfaces, and provides an API that maps closely to the syndication specification entities as well as methods for consuming and persisting syndicated web log communication services information. The framework will by default automatically load any syndication extensions that are present in addition to the syndicated web log communication services information and attempt to handle malformed XML data.

Discovery

The RSD document representing the services needed to read, edit, or communicate with web logging software can be found in the header of the web site. It is represented by a HTML element that looks like this:
<link type="application/rsd+xml" title="{Human readable label for web log communication services endpoint}" href="{Absolute URI that points to the RSD formatted web log communication services information}"/>

Example:
<link type="application/rsd+xml" title="RSD 1.0" href="http://www.example.com/rsd.axd"/>

Consuming syndicated web log communication services information

The RsdDocument class provides two ways of consuming syndicated content that conforms to the RSD syndication format. The first way to consume RSD web log communication services is to use the static Create method exposed by the RsdDocument class, which provides a means of quickly consuming web log communication services information that is available at a given Uri:

using Argotic.Syndication.Specialized;

RsdDocument document    = RsdDocument.Create(new Uri("http://blog.oppositionallydefiant.com/rsd.axd"));
            
foreach(RsdApplicationInterface api in document.Interfaces)
{
    if (api.IsPreferred)
    {
        //  Perform some processing on the application programming interface
        break;
    }
}


The other way to consume RSD formatted web log communication services is to use the overloaded Load method exposed by the RsdDocument class, which provides a means of consuming syndicated web log communication services information from a variety of data sources such as IXPathNavigable, Stream, XmlReader, and Uri:

using System.IO;
using System.Xml;
using System.Xml.Xpath;
using Argotic.Syndication.Specialized;

RsdDocument document   = new RsdDocument();

using (FileStream stream = new FileStream("SampleRsdDocument.xml", FileMode.Open, FileAccess.Read))
{
    document.Load(stream);
}

document    = new RsdDocument();
using (FileStream stream = new FileStream("SampleRsdDocument.xml", FileMode.Open, FileAccess.Read))
{
    XmlReaderSettings settings  = new XmlReaderSettings();
    settings.IgnoreComments     = true;
    settings.IgnoreWhitespace   = true;

    using (XmlReader reader = XmlReader.Create(stream, settings))
    {
        document.Load(reader);
    }
}

document    = new RsdDocument();
using (FileStream stream = new FileStream("SampleRsdDocument.xml", FileMode.Open, FileAccess.Read))
{
    document.Load(new XPathDocument(stream));
}

Sample file that can be used with the above code example: SampleRsdDocument.xml

Last edited Mar 25, 2008 at 4:33 PM by Oppositional, version 3

Comments

No comments yet.