asp.net 用XML生成放便扩展的自定义树
数据源为XML,因此放便扩展。 废话不多说,直接上代码(因一些原因,把部分数据修改或精简了)。 XML代码: 复制代码 代码如下:
"); if (chlidNodesCount > 0) { menuId = GetMenuId(nodeId); treeHtml.AppendFormat("", menuId, (isExpand ? "open-menu" : "close-menu")); } else { treeHtml.Append(""); } treeHtml.Append(" | "); } else { treeHtml.Append(""); } } string url = GetAttributesValue(node.Attributes["Url"]); //链接地址 string title = GetAttributesValue(node.Attributes["Title"]);//链接TITLE信息 string menuNodeId = nodeId.Trim().Length > 0 ? "id='MenuNode" + nodeId + "'" : string.Empty;//树节点ID treeHtml.Append(" | "); if (url.Length > 0 || chlidNodesCount == 0) { if (!isOnlyVip || (isOnlyVip && IsVip))//栏目是否只为VIP开放 { if (url.Length > 0) { treeHtml.AppendFormat("{2}", url, title, showName, eventScript, menuNodeId); } else { treeHtml.AppendFormat("{1}", title, showName, eventScript, menuNodeId); } } else { treeHtml.AppendFormat("{2}", url, title, showName, menuNodeId); } } else { treeHtml.AppendFormat("{2}", menuId, title, showName, eventScript, menuNodeId); } treeHtml.Append(" | "); treeHtml.Append("