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( "");
Display( sjid, space, ref iCount,x );
x.Write( " " );
x.Close();
递归写入XML涵数...
代码:
以下是引用片段: public void Display( string sjid, string space, ref int iCount,StreamWriter x ) { List DepartmentList = OrganizationRule.GetList( sjid );//读取一个列表类,这里是LIST foreach ( CDepartmentInfo aa in DepartmentList ) { strOpinion = aa.BM_CategoryName.Trim().ToString(); x.Write( " x.Write( "\r\n" ); Display( aa.BM_Categorylxpm.ToString().Trim(), Text + space, ref iCount,x ); x.Write( " } |
关键字词: