{"id":114,"date":"2005-06-30T00:32:25","date_gmt":"2005-06-29T22:32:25","guid":{"rendered":"http:\/\/www.maratz.com\/blog\/archives\/2005\/06\/30\/a-few-fixes-for-your-rss-feed\/"},"modified":"2005-07-13T19:48:04","modified_gmt":"2005-07-13T17:48:04","slug":"a-few-fixes-for-your-rss-feed","status":"publish","type":"post","link":"http:\/\/www.maratz.com\/blog\/archives\/2005\/06\/30\/a-few-fixes-for-your-rss-feed\/","title":{"rendered":"A few fixes for your RSS feed"},"content":{"rendered":"<p>Thanks to faithful readers <a href=\"http:\/\/www.louiswalch.com\/\">Louis<\/a> and <a href=\"http:\/\/www.danielmall.com\">Daniel<\/a>, I fixed <a href=\"http:\/\/www.maratz.com\/rss\/\">my feed<\/a>, which wasn\u2019t recognized by certain RSS aggregators. I also apologize for inconvenience to all of you who had such problems. My <a href=\"http:\/\/www.bradsoft.com\/feeddemon\/\">FeedDemon<\/a> will digest anything, so I had no clue something\u2019s wrong. Anyway, shame on me. <!--more--><\/p>\n<h3>Incorrect header syntax<\/h3>\n<p>The problem was in incorrectly labeled header <em>Last Modified<\/em>, which is correctly spelled <em>Last-Modified<\/em> (with dash). In case you missed that lesson, a HTTP header field name can not contain spaces. For example, the <em>Content-Type<\/em> is correct, the <em>Content Type<\/em> is incorrect. Also from the <a href=\"http:\/\/www.w3.org\/Protocols\/HTTP\/Object_Headers.html\">HTTP specs<\/a>:<\/p>\n<blockquote cite=\"http:\/\/www.w3.org\/Protocols\/HTTP\/Object_Headers.html\">\n<p>\u201cAny header fields which are not understood should be ignored.\u201d<\/p>\n<\/blockquote>\n<h3>CDATA\u2013what it\u2019s good for?<\/h3>\n<p>Some blog management systems output feeds with a post content within legible opening <code>&#60;content:encoded><\/code> and closing <code>&#60;\/content:encoded><\/code> tags. This way the original HTML structure (with its\u2019 elements like headings or paragraphs) can be preserved and viewed in your favorite RSS reader. Since XML syntax is very strict, one must also escape those tags by placing <code>&#60;![CDATA[<\/code> before and <code>]]><\/code> after the content, so XML processor knows those tags are not part of the XML structure.<\/p>\n<blockquote cite=\"http:\/\/www.w3.org\/TR\/REC-xml\/#sec-cdata-sect\">\n<p>\u201cCDATA sections MAY occur anywhere character data may occur; they are used to escape blocks of text containing characters which would otherwise be recognized as markup. CDATA sections begin with the string <code>&#60;![CDATA[<\/code> and end with the string <code>]]><\/code>\u201d<\/p>\n<\/blockquote>\n<h3>Absolute vs. relative paths<\/h3>\n<p>If you run your feed through <a href=\"http:\/\/www.feedvalidator.org\/\">Feed Validator<\/a>, it might throw you <a href=\"http:\/\/www.feedvalidator.org\/docs\/warning\/ContainsRelRef.html\">an error regarding relative paths<\/a> to your images or files. This can be fixed by simple <code>preg_replace()<\/code> snippet, for example:<\/p>\n<pre>\r\n&#60;?php\r\n    echo '&#60;content:encoded>&#60;![CDATA[';\r\n    echo preg_replace('\/&#60;(img src|a href)=\"&#92;\/\/si', '&#60;$1=\"http:\/\/' . $_SERVER['HTTP_HOST'] . '\/', $content);\r\n    echo ']]>&#60;\/content:encoded>';\r\n?>\r\n<\/pre>\n<p>The above ensures that every <code>&#60;img src=\"\/image.jpg\" \/><\/code> is replaced with <code>&#60;img src=\"http:\/\/yoursite.com\/image.jpg\" \/><\/code> and also <code>&#60;a href=\"\/file.zip\" \/><\/code> is replaced with <code>&#60;a href=\"http:\/\/yoursite.com\/file.zip\" \/><\/code>. If you use different paths, for example <code>..\/..\/image.jpg<\/code>, the above will not work (actually it might break everything), but you\u2019ve got starting point to tweak it to your needs. Read more about <code>preg_replace()<\/code> in <a href=\"http:\/\/www.php.net\/preg_replace\">PHP manual<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Thanks to faithful readers Louis and Daniel, I fixed my feed, which wasn\u2019t recognized by certain RSS aggregators. I also apologize for inconvenience to all of you who had such problems. My FeedDemon will digest anything, so I had no clue something\u2019s wrong. Anyway, shame on me.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/posts\/114"}],"collection":[{"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/comments?post=114"}],"version-history":[{"count":0,"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/posts\/114\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/media?parent=114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/categories?post=114"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/tags?post=114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}