First release of domframework

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1207 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2014-02-27 08:47:54 +00:00
commit 96cf1c4010
26 changed files with 2125 additions and 0 deletions

40
outputxml.php Normal file
View File

@@ -0,0 +1,40 @@
<?php
require_once ("output.php");
class outputxml extends output
{
public function out ($data)
{
@header("Cache-Control: no-store, no-cache, must-revalidate");
@header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
@header('Last-Modified: '.gmdate ('D, d M Y H:i:s').' GMT');
@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();
}
// function defination to convert array to xml
private function array_to_xml ($data, &$xml)
{
foreach($data as $key => $value)
{
if(is_array($value))
{
$key = is_numeric($key) ? "item$key" : $key;
$subnode = $xml->addChild("$key");
array_to_xml($value, $subnode);
}
else
{
$key = is_numeric($key) ? "item$key" : $key;
$xml->addChild("$key","$value");
}
}
}
}