Class DataProcessor - XML Generator for DHTMLX
$dataprocessor = new DataProcessor( set encoding, default utf-8 )
$dataprocessor = new DataProcessor;
or
$dataprocessor = new DataProcessor('iso-8859-1');
$dataprocessor->action( array( 'key attribute' => 'value attribute' ) )
$dataprocessor->action(
array(
"type" => "inserted",
"sid" => 2,
"tid" => 2
)
);
$dataprocessor->inserted( 'sid', 'tid', optional array( 'key attribute' => 'value attribute' ) )
$dataprocessor->inserted(2, 2, array("details" => "foo"));
$dataprocessor->updated( 'sid', 'tid', optional array( 'key attribute' => 'value attribute' ) )
$dataprocessor->updated(20, 20, array("extra" => "bar"));
$dataprocessor->deleted( 'sid', 'tid', optional array( 'key attribute' => 'value attribute' ) )
$dataprocessor->deleted(8, 8);
$dataprocessor->invalid( 'sid', 'message', optional array( 'key attribute' => 'value attribute' ) )
$dataprocessor->invalid(10, 'Data in first column is not valid');
$dataprocessor->error( 'sid', 'tid', optional array( 'key attribute' => 'value attribute' ) )
$dataprocessor->error(3, 3);
$dataprocessor->header()
$dataprocessor->header();
return
header("Content-type: application/xml; charset=utf-8");
$dataprocessor->result()
echo $dataprocessor->result();
Print XML
<?php
include_once 'DHX.php';
$dataprocessor = new DataProcessor;
$dataprocessor->action(
array(
"type" => "inserted",
"sid" => 2,
"tid" => 2
)
);
$dataprocessor->header();
echo $dataprocessor->result();
?>
Result
<?xml version="1.0" encoding="utf-8"?>
<data>
<action type="inserted" sid="2" tid="2"/>
</data>
<?php
include_once 'DHX.php';
$dataprocessor = new DataProcessor;
$dataprocessor->inserted(15, 15, array("details" => "successfully added"));
$dataprocessor->header();
echo $dataprocessor->result();
?>
Result
<?xml version="1.0" encoding="utf-8"?>
<data>
<action type="inserted" sid="15" tid="15">successfully added</action>
</data>
<?php
include_once 'DHX.php';
$dataprocessor = new DataProcessor('iso-8859-1');
$dataprocessor->invalid(300, "Data in first column is not valid");
$dataprocessor->header();
echo $dataprocessor->result();
?>
Result
<?xml version="1.0" encoding="iso-8859-1"?>
<data>
<action type="invalid" sid="300" message="Data in first column is not valid"/>
</data>
<?php
include_once 'DHX.php';
$dataprocessor = new DataProcessor('iso-8859-1');
$dataprocessor->updated(132, 132, array("extra" => "new value for first column"));
$dataprocessor->header();
echo $dataprocessor->result();
?>
Result
<?xml version="1.0" encoding="iso-8859-1"?>
<data>
<action type="updated" sid="132" tid="132" extra="new value for first column"/>
</data>
Lucas Tiago de Moraes