XML Output with the Yii Framework

My quick solution for getting the Yii Framework to display XML data. I’m just going to give the code from a project that I’m working, so substitute in your own names where necessary. OverviewFiles to create: protected/views/[your_class]/[your_action].php protected/views/layouts/[your_xml_layout].php Files to modify: protected/controllers/[your_controller].php In general, the approach is as follows. Create a layout that wraps our XML and outputs the XML header. Step 1: Create The View FilesFor the layout file, make sure you have at least the bolded text below included: File: protected/views/layouts/[your_xml_layout].php <?php header(“Content-type: text/xml”); ?><?php echo ‘<?xml version=”1.0″ encoding=”UTF-8″?>’?><Response> <Tag><?php echo $content; ?></Tag></Response> I’ll leave it up to you to figure out how you want to wrap your… Continue reading XML Output with the Yii Framework