In this example we are going to propose that some CRM software needs to update the list of users subscribed to a mailing list in Expression Engine.
By publishing the feed as XML we can allow other applications to read and interpret the data.
Creating XML feeds of any data stored within Expression Engine is simple.
My preference is to create a new template group called ‘api’. This allows me to add password protection if required.
Create a new template and then under template type choose XML. In this example we will call the template ‘mailing_list’
You can use weblog tags and even custom queries to output XML.
Here’s how the template looks:
<?xml version="1.0" encoding="UTF-8"?>
{exp:query sql="select email from exp_mailing_list where list_id = 2 order by email asc"}
<subscriber>
<email>{email}</email>
</subscriber>
{/exp:query}
Now when you hit the page http://www.yoursite.com/api/ you will see an XML feed of your subscribers.
