前端之家收集整理的这篇文章主要介绍了
使用DHTMLX Tree 输出(树状结构),
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
ob_end_clean(); // 关闭缓存区
error_reporting(E_ALL ^ E_NOTICE);
$select = 0;
header("Content-type:text/xml");
$xml = '<?xml version="1.0" encoding="UTF-8"?>';
if ($uid == 0) {
$tid = 0;
} else {
$tid = $id;
}
$xml .= '<tree id ="' . $tid . '">';
if (! empty($cates)) {
foreach ($cates as $k => $v) {
$child = $result->getChildNodeBy($v['title']);
if (! empty($child)) {
foreach ($child as $key => $obj) {
$xml .= '<item child="1" text="' . $v['title'] .
'" id="' . $v['id'] . '" >';
}
} else {
if ($k == 0) {
$xml .= '<item text="' . $v['title'] . '" id="' .
$v['id'] . '" select="1" >';
} else {
$xml .= '<item text="' . $v['title'] . '" id="' .
$v['id'] . '" >';
}
}
$xml .= "<userdata name='parent_id'>" . $v['parent_id'] .
"</userdata>";
$xml .= '</item>';
}
}
$xml .= "</tree>";
return $xml;