使用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;



你可能感兴趣的:(xml,PHP,tree,DHTMLX)