I've just come across a BBC API that will let you query schedule information on all the BBC channels. It's good fun to mess around with. Below you'll find the code to show the schedule for now and the rest of the day on BBC one. Check out the code and the API and have fun mashing! :) 

protected void Page_Load(object sender, EventArgs e)
{
    //GS - Build a URL to get now and next programme info for BBC One
    string url = 
        @"http://www0.rdthdo.bbc.co.uk/cgi-perl/api/query.pl?";
    url += "method=bbc.schedule.getProgrammes&";
    url += "channel_id=BBCOne&";
    url += "detail=schedule&";
    url += "limit=100";

    //GS - Fetch the schedule information
    XPathDocument xpd = null;
    try
    {
        xpd = new XPathDocument(url);
    }
    catch (XmlException xe)
    {
        Response.Write("The following xml error occurred: " +
            xe.Message);
        Response.End();
        return;
    }

    //GS - Create a navigator
    XPathNavigator xpn = xpd.CreateNavigator();

    //GS - Pull out the schedule information from the xml
    string synopsis = "";
    string start = "";
    string name = "";
    string duration = "";

    try
    {
        XPathNodeIterator xpni = 
            xpn.Select(@"/rsp/schedule/programme");

        Response.Write("<h1>Now and Rest of the Day on the BBC</h1>");

        //GS - Write out info for each programme returned
        while (xpni.MoveNext())
        {
            name = xpni.Current.GetAttribute("title", "");
            Response.Write(name);
            Response.Write("<ul>");

            start = 
                 xpni.Current.SelectSingleNode("start").InnerXml;
            Response.Write("<li>" + start + "</li>");

            duration = 
                xpni.Current.SelectSingleNode("duration").InnerXml;
            Response.Write("<li>" + duration + "</li>");

            synopsis = 
                xpni.Current.SelectSingleNode("synopsis").InnerXml;
            Response.Write("<li>" + synopsis + "</li>");

            Response.Write("</ul><hr>");
        }            
    }
    catch (XPathException xpe)
    {
        Response.Write("The following XPath exception occurred: "
            + xpe.Message);
        Response.End();
        return;
    }
}

Tags: ,