Class Tree - XML Generator for DHTMLX
$tree = new Tree( set encoding, default utf-8 )
$tree = new Tree;
or
$tree = new Tree('iso-8859-1');
id
$tree->id = 0; // default 0
radio
$tree->radio = 0;
order
$tree->order = "asc";
$tree->item( array( 'key attribute' => 'value attribute' ) )
$tree->item(
array(
"id" => "p1",
"text" => "parent item 1",
"select" => "1",
"call" => "1"
"userdata" => array(
"name" => "some1",
"value" => "Value 1"
),
"item" => array(
array(
"id" => "c1-0",
"text" => "child item 1"
),
array(
"id" => "c1-1",
"text" => "child item 2"
)
)
)
);
$tree->start( array( 'key attribute' => 'value attribute' ) ) and $form->end()
$tree->start(
array(
"id" => "p1",
"text" => "parent item 1",
"select" => "1",
"call" => "1"
)
);
$tree->item(
array(
"id" => "c1-0",
"text" => "child item 1"
),
array(
"id" => "c1-1",
"text" => "child item 2"
)
);
$tree->end();
$tree->itemtext( ' value ' )
$tree->itemtext("Value");
$tree->userdata( array( 'key attribute' => 'value attribute' ) )
$tree->userdata(
array(
"name" => "some1",
"value" => "Value1"
),
array(
"name" => "some2",
"value" => "Value2"
)
);
$tree->header()
$tree->header();
return
header("Content-type: application/xml; charset=utf-8");
$tree->result()
echo $tree->result();
Print XML
Mode 1
<?php
include_once 'DHX.php';
$tree = new Tree;
$tree->item(
array(
"id" => "p1",
"text" => "parent item 1",
"select" => "1",
"call" => "1",
"itemtext" => "Value Item Text",
"userdata" => array(
"name" => "some1",
"value" => "Value 1"
),
"item" => array(
array(
"id" => "c1-0",
"text" => "child item 1"
),
array(
"id" => "c1-1",
"text" => "child item 2"
)
)
)
);
$tree->header();
echo $tree->result();
?>
Result
<?xml version="1.0" encoding="utf-8"?>
<tree id="0">
<item id="p1" text="parent item 1" select="1" call="1">
<itemtext>
<![CDATA[ Value Item Text ]]>
</itemtext>
<userdata name="some1">Value 1</userdata>
<item id="c1-0" text="child item 1"/>
<item id="c1-1" text="child item 2"/>
</item>
</tree>
Mode 2
<?php
include_once 'DHX.php';
$tree = new Tree("iso-8859-1");
// start p1
$tree->start(
array(
"id" => "p1",
"text" => "parent item 1",
"select" => "1",
"call" => "1",
)
);
$tree->itemtext("Value Item Text");
$tree->userdata(
array(
"name" => "some1",
"value" => "Value 1"
)
);
$tree->item(
array(
"id" => "c1-0",
"text" => "child item 1"
),
array(
"id" => "c1-1",
"text" => "child item 2"
)
);
$tree->end(); // end p1
$tree->header();
echo $tree->result();
?>
Result
<?xml version="1.0" encoding="iso-8859-1"?>
<tree id="0">
<item id="p1" text="parent item 1" select="1" call="1">
<itemtext>
<![CDATA[ Value Item Text ]]>
</itemtext>
<userdata name="some1">Value 1</userdata>
<item id="c1-0" text="child item 1"/>
<item id="c1-1" text="child item 2"/>
</item>
</tree>
Lucas Tiago de Moraes