Code Test

Just a quick test of the SyntaxHighlighter script and the plugin for Windows Live Writer. This is the LINQ to XML code that spits out my RSS feed.

Response.ContentType = "text/xml";

List<BlogPost> posts = BlogPostManager.GetLastPublishedBlogPosts(10);
DateTime lastBuildDate = posts[0].PostedDate.Value;

XDocument doc = new XDocument(
    new XDeclaration("1.0", "utf-8", "yes"),
    new XElement("rss",
        new XAttribute("version", "2.0"),
        new XElement("channel",
            new XElement("title", "XWeb: Home of Jeremy McPeak"),
            new XElement("description", "The personal blog of Jeremy McPeak"),
            new XElement("link", "http://www.wdonline.com"),

            new XElement("language", "en-us"),
            new XElement("copyright", String.Format("Copyright {0}", DateTime.Now.Year)),
            new XElement("lastBuildDate", lastBuildDate.ToUniversalTime()),
            new XElement("managingEditor", "jwmcpeak&#064;gmail.com"),
            new XElement("webMaster", "Jeremy McPeak"),
            
            from bp in posts
            select new XElement("item",
                new XElement("link", String.Format("http://www.wdonline.com/blog/{0}/{1:00}/{2}.aspx", 
                                         bp.PostedDate.Value.Year, bp.PostedDate.Value.Month, bp.UniqueName)),
                new XElement("title", bp.Title),
                new XElement("description", bp.Post),
                new XElement("pubDate", bp.PostedDate.Value.ToUniversalTime())
            )
        )
    )
);

Response.Write(doc);

I have no idea what kind of HTML this spits out. I guess I should've checked before giving it a shot ;)

9/8/2008 2:21:35 PM | Tags: .NET, ASP.NET, Blog, C#, LINQ, Web, XML
© 2008 Jeremy McPeak