Hello, my question is how I can send clean xml from this class. It is simplified, so there is the least off trouble that could have been caused by other things.
The problem now is that the error says that the xml declaration should occur at the top off the document.
What is the right way to avoid this kind off errors? Is there some php function that would do this for me?
I have to mention that I am doing this the REST way. So, no hassle with soap servers, xml-rpc servers.
The first part is the instantiation off the class in the index.php.
The class is in the included file.
<?php
include 'controller/' . 'gpsController.php';
$gps=new gpsController('eenwaarde');
$gps->setgpsloc();
exit();
?>
<?php
class gpsController {
// extends controller
public $url;
function __construct($url) {
$this->url = $url;
}
public function setgpsloc() {
$gebruikersnaam="kabouter";
$status_code = 2;
header('Content-type: text/xml');
$output= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
$output.= "<response>\n";
$output.= "\t<status>$status_code</status>\n";
$output.= "\t<fout>$gebruikersnaam</fout>\n";
$output.= "</response>";
echo trim($output);
}
public function index() {
}
}
?>
Thanks, Richard