Rather than using strings to build the XML you ought to look at one of the existing classes to do all the heavy lifting - they are after all designed for this purpose. Looking at the xml in the question it does not appear valid XML as there is no root node for the content. The following ought to help get started.
<?php
$channel = "15";
$start = "20180124021100 +0200";
$stop = "20180124031500 +0200";
$title = "news";
$desc = "show number 50";
/* file path to saved xml document */
$xmlfile= __DIR__ . '/xmlfile.xml';
/* whether to display XML in browser or simply save */
$displayxml=true;
/* create DOMDocument and set args */
$dom=new DOMDocument('1.0','utf-8');
$dom->standalone=true;
$dom->formatOutput=true;
$dom->recover=true;
$dom->strictErrorChecking=true;
/* a ROOT node for the document */
$rootnode='programmes';
/* if the file already exists, open it */
if( realpath( $xmlfile ) ){
$dom->load( $xmlfile );
$root=$dom->getElementsByTagName( $rootnode )->item(0);
} else {
/* File does not exist, create root elements & content */
$root=$dom->createElement( $rootnode );
$dom->appendChild( $root );
$ochan=$dom->createElement('channel');
$ochan->setAttribute('id',1);
$root->appendChild( $ochan );
$odisp=$dom->createElement('display-name',1);
$odisp->setAttribute('lang','he');
$ochan->appendChild( $odisp );
}
/* process variables for new record/programme */
if( isset( $channel, $start, $stop, $title, $desc ) ){
$oprog=$dom->createElement('programme');
$root->appendChild( $oprog );
$oprog->setAttribute('start',$start);
$oprog->setAttribute('end',$stop);
$oprog->setAttribute('channel',$channel);
$otitle=$dom->createElement('title',$title);
$oprog->appendChild($otitle);
$otitle->setAttribute('lang','he');
$odescr=$dom->createElement('desc',$desc);
$oprog->appendChild($odescr);
$odescr->setAttribute('lang','he');
}
/* save the file */
$dom->save( $xmlfile );
/* if you want to see the generated xml in the browser */
if( $displayxml ){
header('Content-Type: application/xml');
echo $dom->saveXML();
}
?>