<?php
	require_once '../../autoload.php';
		
	$conn = get_dbconnection();
	
	$answer = "<modalities>";
	
	if ( $conn )
	{
		$sql = "select id,name, modalitytype from device where removed=false order by modalitytype";
		
		if ( $query = pg_query($conn,$sql) )
		{
			while ( $row = pg_fetch_row($query) )
			{
				$answer .= "<modality id=\"".$row[0]."\" name=\"".$row[1]."\" type=\"".$row[2]."\" ></modality>";
			}
		}
	}
	
	$answer .= "</modalities>";

	header ('Content-type: text/xml' );
	
	echo $answer;
?>