This is a pretend XML RSS feed, so I can append visible notes to the output. The real one is identical XML generation, but without all this HTML. This resource is the first piece of XML this CMS is rendering. At present, I'm not even sure if I need to import any libraries, which feels weird. The real resource also has the correct content headers.
I pulled the RSS spec up 1 and a reference implementation 2 and wrote code to emit this text. The output XML is as follows, please use the view source in the footer if you are interested. For the real one, I will use the RSS date format, rather than the sites more readable date format.
Reference RSS feed
This generated text is valid XML, but fails the RSS requirement of “new files since last publication”. I guess I could edit this to only return articles added in the last week (or some other time period). As soon as I deployed this I realised I am updating the files timestamps at least once a week. I ought to start using a more complicated publication tool to avoid this. EDIT some time 2015: I changed publication process, this problem is no more.
It feels really quaint to hand build XML, rather than rasterising it through a library.
<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0"> <urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9' http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <channel> <title>OwenBeresford's very wordy site</title> <link>http://owenberesford.me.uk</link> <description>um, I don't know what to put in here, I'm writing a tech demo, not prose.</description> <language>en-uk</language> <pubDate>2017-08-22T14:11:09+01:00</pubDate> <lastBuildDate>2017-08-22T14:11:09+01:00</lastBuildDate> <item> <title>The economic and commercial justification for OOP</title> <description>Commercial justification for using common engineering practice of OO. Please read if you are a business person.</description> <pubDate>2017-01-30T23:48:06+00:00</pubDate> <guid isPermaLink="true">http://owenberesford.me.uk/resource/justify-oop</guid> </item> </channel> </urlset> </rss>
For a sitemap, a different protocol is probably more use 1. This is the same XML that it looks like the rest of the planet is using (I checked my employers site, a couple of tech publishers, and google). My current XML validator says this is invalid. I assert that this XML error isnt causing anyone ptoblems, or at least one of those companies would have addresssed the issue.
<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0"> <url> <loc>owenberesford.me.uk/</loc> <lastmod>2017-04-23T16:53:38+01:00</lastmod> <changefreq>weekly</changefreq> <priority>0.8</priority> </url> <url> <loc>http://owenberesford.me.uk/resource/justify-oop</loc> <lastmod>2017-01-30T23:48:06+00:00</lastmod> <changefreq>monthly</changefreq> </url> </urlset>