Web Design, Development & Marketing
acuras services: Website Design & Development E-commerce Solutions Content Management Systems Online Marketing & Social Media Corporate Branding Social Media Training
Get in touch... Email Us: info@acuras.co.uk
acuras blog:7 Quick Tips to Keep Your SEO On Track in 2012 7 Social Media & SEO Tactics Businesses Will Adopt in 2012 latest posts:We are now trading as a Limited company Recent Work: Digital Marketing Material and Website Re-Designs Affordable Web Hosting and Domain Name Registration New Acuras Logo Coming Soon... Barclaycard ePDQ CPI Integrations HSBC XML API / CPI E-commerce Integrations Photoshop to Valid XHTML/CSS Coding Service Recommended Open Source Invoicing System Reasons Businesses should Embrace the Web blog archive:
Web Development ArticlesXML / PHP: Create an RSS Feed Using PHP
Published: 26th Mar 2006
Here's a simple way to create an XML file using PHP. This can be a useful way of automatically updating a basic RSS feed you may have set up. Of course, you can adapt the code to suit your requirements. One hurdle you may have to overcome is permissions. Your script actually needs to be able to write to the location you wish to create your XML file in! Right, so here's some PHP code for you:
You can make this code more useful by looping over a set of items you wish to put into the XML file. The basic principle for RSS XML feed creation is pretty straightforward. It's up to your own brilliance as to how you use it! The few lines of code at the end assume that you are clearing the exisiting XML file's content and reloading it all. This is perfectly fine for relatively small file sizes and it's a good method if you wish to keep an RSS file a certain length i.e. you just want your 10 most recent articles in the feed. Instead of mucking around deleting one item off the end and adding the new one to the beginning just wipe it clean and load the 10 most recent items from your database (or wherever it is you keep your wonderfully crafted content). Another point worthy of noting is the use of the <![CDATA[ ... ]]> tag in the description (content) field of the XML items. This enables you to put anything you like between those tags and not worry about quotes or html tags screwing up your XML file syntax. Well I hope that has been moderately informative. Comments and questions are always welcome. Related LinksRelated Articles / PostsBarclaycard ePDQ CPI Integrations (27/05/2009) HSBC XML API / CPI E-commerce Integrations (02/04/2009) Recommended Open Source Invoicing System (25/03/2009) Recent Recommended Links - October 2008 (03/10/2008) Controlling PHP Register Globals Using .htaccess File (04/03/2008) |
||