logo 广告
Loading...
 导航 所在位置:论坛首页 -> ┈┋电脑网络┋┈ -> Asp/Asp.Net教程 -> asp.net递归生成XML树的示例
回复
标题:asp.net递归生成XML树的示例收藏 编辑 删除 楼主 | 上一篇 下一篇
金利英
头像
等级:社区游民
权限:普通用户
积分:22
金钱:225
声望:44
经验:44
发帖数:79
注册:2008年5月14日
资料 短消息2008-7-20 11:18:24

asp.net递归生成XML树的示例
代码:
以下是引用片段:
//CDepartmentInfo 类别实体类
//sjid :与大类别关联ID
//space:只是一个标记
//strOpinion用来存放类名
string sjid = "0";
string space = "+";
string strOpinion = "";
string paths = @"E:\test";
string FILE_NAME = paths + "\\BMCategory.XML";
        flag = true;
        StreamWriter sr = File.CreateText( "BMCategory" );
        sr.Close();
        StreamWriter x = new StreamWriter( FILE_NAME, true, System.Text.Encoding.Default );
       
        x.Write( "<R>");
        Display( sjid, space, ref iCount,x );
        x.Write( "</R>" );
        x.Close();     
 
递归写入XML涵数...
代码: 以下是引用片段:
public void Display( string sjid, string space, ref int iCount,StreamWriter x )
        {
            
            List<CDepartmentInfo> DepartmentList = new List<CDepartmentInfo>();
            DepartmentList = OrganizationRule.GetList( sjid );//读取一个列表类,这里是LIST
            foreach ( CDepartmentInfo aa in DepartmentList )
            {
                strOpinion = aa.BM_CategoryName.Trim().ToString();
                 x.Write( "<DSTree"+aa.BM_Categorylxpm.Trim()+"  text=\"" + aa.BM_CategoryName.Trim() + "\"  treeId=\"" + aa.BM_Categorylxpm.Trim() + "\"  mspace=\"栏目管理\">"+ strOpinion );
                 x.Write( "\r\n"  );
                 Display( aa.BM_Categorylxpm.ToString().Trim(), Text + space, ref iCount,x );
                 x.Write( "</DSTree" + aa.BM_Categorylxpm.Trim() + ">" ); 
            }

方法是参考网上用ASP来生成的...

签名

2008-7-20 11:18:24 顶部
第1页 共页 共0个回复     <<    >>    
 快速回复
  • 支持UBB,HTML标签

  • 高级回复

  • 操作选项:评分 加精 解精 奖惩 设专题 设公告 解公告 固顶 总固顶 解固顶 结帖 解结帖 锁帖 解锁 移帖 删帖
      首页 | 购买指南 | 虚拟主机 | 特色介绍 | 下载中心 | 支付方式
    Copyright 2004-2008 BBSGood.com Powered By: BBSGood.Speed Version 5.0
      咨询电话:0575-85513832、0575-85513825(传真)、7*24小时咨询服务:13606552007 不良信息举报中心 浙ICP备05029817号
      业务QQ:38958768、客服QQ1:415896239、客服QQ2:343896043、MSN:jccsxx@hotmail.com