<?php
/////////////////////////////////
///////  Array to RSS   /////////
/////////////////////////////////


//if $format is not set we output XML as default
if ( isset($_GET['dataformat']) ){
	$dataformat = $_GET['dataformat'];
}else{
	$dataformat = "xml";
}


include("exportrss.php");

// Parse XML/RSS 2.0 feed
$feed = new ExportRSS($_GET['xml_source'], "2.0");



////////////////////////////
//Start to display the DATA:
////////////////////////////
switch ( $dataformat ) { 
			
	case "xml":
		
		header ("Content-Type: text/xml; charset=UTF-8");
	
		echo '<?xml version="1.0"?>';
		
		echo '<NEWS>';

			foreach($feed->get_data() as $item) {
				 
				echo '<ITEM>';
					echo '<TITLE>'.htmlspecialchars($item['title']).'</TITLE>';
				echo '</ITEM>';
				 
			}
			
		echo '</NEWS>';
		break;

	
	
	case "json":
				
		echo json_encode( $feed->get_data() );			
		break;

	
	default:
	
		echo "ERROR: The format selected does not exist.";
		break;

} //end switch
?>