Class DataView - XML Generator for DHTMLX
$dataview = new DataView( set encoding, default utf-8 )
$dataview = new DataView;
or
$dataview = new DataView('iso-8859-1');
pos
$dataview->pos = 100;
total_count
$dataview->total_count = 1000;
$dataview->item( array( 'key attribute' => 'value attribute' ) )
$dataview->item(
array(
"id" => 1,
"Package" => "acx100-source",
"Version" => "20080210-1.1",
"Maintainer" => "Stefano Canepa <[email protected]>"
)
);
$dataview->file( array( 'key attribute' => 'value attribute' ) )
$dataview->file(
array(
"id" => 1,
"name" => "Classes New",
"type" => "dir"
)
);
$dataview->header()
$dataview->header();
return
header("Content-type: application/xml; charset=utf-8");
$dataview->result()
echo $dataview->result();
Print XML
<?php
include_once 'DHX.php';
$dataview = new DataView;
$dataview->item(
array(
"id" => 1,
"Package" => "acx100-source",
"Version" => "20080210-1.1",
"Maintainer" => "Stefano Canepa <[email protected]>"
),
array(
"id" => 2,
"Package" => "alien-arena-browser",
"Version" => "7.0-1",
"Maintainer" => "Debian Games Team <[email protected]>"
),
array(
"id" => 3,
"Package" => "alsa-firmware-loaders",
"Version" => "1.0.21-1",
"Maintainer" => "Debian ALSA Maintainers <[email protected]>"
)
);
$dataview->header();
echo $dataview->result();
?>
Result
<?xml version="1.0" encoding="utf-8"?>
<data>
<item id="1">
<Package>
<![CDATA[ acx100-source ]]>
</Package>
<Version>
<![CDATA[ 20080210-1.1 ]]>
</Version>
<Maintainer>
<![CDATA[ Stefano Canepa <[email protected]> ]]>
</Maintainer>
</item>
<item id="2">
<Package>
<![CDATA[ alien-arena-browser ]]>
</Package>
<Version>
<![CDATA[ 7.0-1 ]]>
</Version>
<Maintainer>
<![CDATA[ Debian Games Team <[email protected]> ]]>
</Maintainer>
</item>
<item id="3">
<Package>
<![CDATA[ alsa-firmware-loaders ]]>
</Package>
<Version>
<![CDATA[ 1.0.21-1 ]]>
</Version>
<Maintainer>
<![CDATA[ Debian ALSA Maintainers <[email protected]> ]]>
</Maintainer>
</item>
</data>
<?php
include_once 'DHX.php';
$dataview = new DataView("iso-8859-1");
$dataview->file(
array(
"name" => "Classes",
"type" => "dir",
"modifdate" => "2008-01-28 16-09-31"
),
array(
"name" => "Downloads",
"type" => "dir",
"modifdate" => "2008-01-28 16-09-31"
),
array(
"name" => "Java",
"type" => "dir",
"modifdate" => "2008-01-28 16-09-31"
),
array(
"name" => "Apple.jpg",
"type" => "file",
"filesize" => "18637",
"modifdate" => "2008-01-28 17-02-23"
),
array(
"name" => "My working place.jpg",
"type" => "file",
"filesize" => "231020",
"modifdate" => "2007-04-20 11-12-20"
),
array(
"name" => "Price List 1.xls",
"type" => "file",
"filesize" => "110145",
"modifdate" => "2008-12-28 13-08-21"
),
array(
"name" => "Price List 2.xls",
"type" => "file",
"filesize" => "112651",
"modifdate" => "2008-01-01 13-18-00"
),
array(
"name" => "Favorite songs.mpu",
"type" => "file",
"filesize" => "534",
"modifdate" => "2006-01-00 12-10-20"
)
);
$dataview->header();
echo $dataview->result();
?>
Result
<?xml version="1.0" encoding="iso-8859-1"?>
<data>
<item name="Classes" type="dir">
<modifdate>2008-01-28 16-09-31</modifdate>
</item>
<item name="Downloads" type="dir">
<modifdate>2008-01-28 16-09-31</modifdate>
</item>
<item name="Java" type="dir">
<modifdate>2008-01-28 16-09-31</modifdate>
</item>
<item name="Apple.jpg" type="file">
<filesize>18637</filesize>
<modifdate>2008-01-28 17-02-23</modifdate>
</item>
<item name="My working place.jpg" type="file">
<filesize>231020</filesize>
<modifdate>2007-04-20 11-12-20</modifdate>
</item>
<item name="Price List 1.xls" type="file">
<filesize>110145</filesize>
<modifdate>2008-12-28 13-08-21</modifdate>
</item>
<item name="Price List 2.xls" type="file">
<filesize>112651</filesize>
<modifdate>2008-01-01 13-18-00</modifdate>
</item>
<item name="Favorite songs.mpu" type="file">
<filesize>534</filesize>
<modifdate>2006-01-00 12-10-20</modifdate>
</item>
</data>
Lucas Tiago de Moraes