* outputxml: if the provided data are XML, do not change them and just display them with the headers

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3655 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2017-05-12 19:00:16 +00:00
parent 6673974a80
commit 85ce83ff39

View File

@@ -17,13 +17,22 @@ class outputxml extends output
@header('Cache-Control: post-check=0, pre-check=0', false);
@header('Pragma: no-cache');
@header ("Content-Type: text/xml");
$xml = new SimpleXMLElement ("<?xml version=\"1.0\"?><root></root>");
// function call to convert array to xml
if (!is_array ($data))
$data = array ($data);
$this->array_to_xml ($data, $xml);
//saving generated xml file
print $xml->asXML();
if (is_string ($data) && substr ($data, 0, 6) === "<?xml ")
{
// If data is already in XML, do not modify it !
// Like RSS, the XML is constructed by the rss class
echo $data;
}
else
{
$xml = new SimpleXMLElement ("<?xml version=\"1.0\"?><root></root>");
// function call to convert array to xml
if (!is_array ($data))
$data = array ($data);
$this->array_to_xml ($data, $xml);
//saving generated xml file
print $xml->asXML();
}
if (!defined ("PHPUNIT"))
exit;
}