<?php
	include '../../autoload.php';
	
	$id=$_POST['id'];
	if(!isset($_SESSION['language']))
		$_SESSION['language']="FR";
	$language=$_SESSION['language'];
	
	$conn = get_dbconnection();
	$sql = "select quaad_point.id,istitle,description,level2||coalesce(nullif('.'||level3,'.-1'),'')||coalesce(nullif('.'||level4,'.-1'),''),language from quaad_point, quaad_description where quaad_point.id=".$id."  and quaad_point.id = quaad_description.id_quaadpoint and language='".$language."'";
	$answer="<root>";
	$query = pg_query($conn,$sql);
	if($query)
	{
		if ($row = pg_fetch_row($query))
		{
			$answer.="<description>".htmlspecialchars($row[2], ENT_XML1, 'UTF-8')."</description>";
			$answer.="<num>".htmlspecialchars($row[3], ENT_XML1, 'UTF-8')."</num>";
		}
	}
	
	$answer.="</root>";
	header('Content-Type: text/xml');
	echo $answer;
?>