简单无限级树 生成XML代码

原创 2004年08月19日 12:25:00
None.gif????????private?void?makeXml(string?xmlPath)
ExpandedBlockStart.gif????????
{
InBlock.gif????????????
string?sqlStr?=?"SELECT?*?FROM?tree?ORDER?BY?treenode";
InBlock.gif????????????OleDbDataAdapter?da?
=?new?OleDbDataAdapter(sqlStr,?conn);
InBlock.gif????????????DataTable?dt?
=?new?DataTable();
InBlock.gif????????????da.Fill(dt);
InBlock.gif????????????da.Dispose();
InBlock.gif????????????
int?ptreeDepth?=?-1;
InBlock.gif????????????
int?treeDepth?=?0;
InBlock.gif????????????XmlTextWriter?xw?
=?new?XmlTextWriter(xmlPath,?null);
InBlock.gif????????????xw.Formatting?
=?Formatting.Indented;
InBlock.gif????????????xw.IndentChar?
=?' ';
InBlock.gif????????????xw.Indentation?
=?1;
InBlock.gif????????????xw.WriteStartDocument();
InBlock.gif????????????xw.WriteStartElement(
"treeRoot");
InBlock.gif
InBlock.gif????????????
foreach(DataRow?dr?in?dt.Rows)
ExpandedSubBlockStart.gif????????????
{
InBlock.gif????????????????treeDepth?
=?charCount(dr["treenode"].ToString(),?',');
InBlock.gif
InBlock.gif????????????????
if(treeDepth?==?ptreeDepth)
ExpandedSubBlockStart.gif????????????????
{
InBlock.gif????????????????????xw.WriteEndElement();
InBlock.gif????????????????????xw.WriteStartElement(
"treeBranch");
ExpandedSubBlockEnd.gif????????????????}

InBlock.gif????????????????
else?if(treeDepth?==?ptreeDepth?+?1)
ExpandedSubBlockStart.gif????????????????
{
InBlock.gif????????????????????xw.WriteStartElement(
"treeBranch");
ExpandedSubBlockEnd.gif????????????????}

InBlock.gif????????????????
else
ExpandedSubBlockStart.gif????????????????
{
InBlock.gif????????????????????
for(int?i?=?0;?i?<?ptreeDepth?-?treeDepth;?i++)
ExpandedSubBlockStart.gif????????????????????
{
InBlock.gif????????????????????????xw.WriteEndElement();
ExpandedSubBlockEnd.gif????????????????????}

InBlock.gif
InBlock.gif????????????????????xw.WriteEndElement();
InBlock.gif????????????????????xw.WriteStartElement(
"treeBranch");
ExpandedSubBlockEnd.gif????????????????}

InBlock.gif
InBlock.gif????????????????xw.WriteAttributeString(
"treeid",?dr["treeid"].ToString());
InBlock.gif????????????????xw.WriteAttributeString(
"treeNode",?dr["treenode"].ToString());
InBlock.gif????????????????xw.WriteElementString(
"treeTitle",?dr["treetitle"].ToString());
InBlock.gif????????????????ptreeDepth?
=?treeDepth;
ExpandedSubBlockEnd.gif????????????}

InBlock.gif
InBlock.gif????????????
for(int?i?=?0;?i?<?treeDepth;?i++)
ExpandedSubBlockStart.gif????????????
{
InBlock.gif????????????????xw.WriteEndElement();
ExpandedSubBlockEnd.gif????????????}

InBlock.gif
InBlock.gif????????????xw.WriteEndElement();
InBlock.gif????????????xw.WriteEndElement();
InBlock.gif????????????xw.Flush();
InBlock.gif????????????xw.Close();
ExpandedBlockEnd.gif????????}

None.gif
None.gif????????
private?void?lbMakeXml_Click(object?sender,?System.EventArgs?e)
ExpandedBlockStart.gif????????
{
InBlock.gif????????????makeXml(Server.MapPath(
"tree.xml"));
ExpandedBlockEnd.gif????????}

简单无限级树 HTML代码

@ Page language="c#" %>@ Import namespace="System.Data" %>@ Import namespace="System.Data.OleDb" %>@...
  • ericfine
  • ericfine
  • 2004-08-17 17:55:00
  • 1468

无限级树(Java递归)

  • 2008年11月12日 09:33
  • 7KB
  • 下载

Java无限级树(递归)超实用

Java无限级树(递归)超实用
  • u010407050
  • u010407050
  • 2015-07-28 17:02:28
  • 3968

无限级目录树数据结构前端实现

无限级目录树数据结构的前端实现
  • qq_22555107
  • qq_22555107
  • 2017-11-14 13:40:57
  • 587

无限级树源码无限级树源码

  • 2008年12月17日 17:40
  • 643KB
  • 下载

利用TreeView控件动态生成无限级树

利用TreeView控件动态生成无限级树 项目需要,有一个树形菜单需要动态生成,联想到TreeView控件,决定用TreeView来实现首先注意到了TreeView控件有一个属性TreeNodeSrc...
  • loveangela
  • loveangela
  • 2006-08-09 11:37:00
  • 954

TreeUtil 数据库菜单生成无限级树形结构

1、项目需求:     从数据库从加载所有的菜单出来,菜单中有  id,parentId,name字段    希望能有一个工具帮我进行树形结构重组;   实例类: package...
  • jeexuan
  • jeexuan
  • 2017-11-24 01:51:06
  • 287

PHP+JS无限级可伸缩菜单详解

//所用数据表的结构CREATE TABLE `cr_columninfo` (  `columnid` int(4) NOT NULL auto_increment,  `columnfatheri...
  • chenhang21367
  • chenhang21367
  • 2007-04-20 21:27:00
  • 869

php实现无限级树型菜单(函数递归算法)

大概步骤如下: 首先到数据库取数据,放到一个数组, 然后把数据转化为一个树型状的数组, 最后把这个树型状的数组转为html代码。 也可以将第二步和第三步合为一步。 详细如下: 1。数据库设计: ...
  • u014649204
  • u014649204
  • 2014-04-19 17:30:32
  • 2483

JS无限级树型菜单(带复选框、动态添加节点)

  • 2015年06月02日 12:05
  • 75KB
  • 下载
收藏助手
不良信息举报
您举报文章:简单无限级树 生成XML代码
举报原因:
原因补充:

(最多只允许输入30个字)