asp.net|xml| Generation xml| Sample | recursion
An example of asp.net recursive generation of XML trees
Code:
The following is a reference fragment:
Cdepartmentinfo category entity Class
Sjid: Association ID with large category
Space: Just a mark
Stropinion used to store class names
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 (); |
Recursive write XML number ...
Code:
The following is a reference fragment:
public void Display (string Sjid, string space, ref int icount,streamwriter x)
{
list<cdepartmentinfo> departmentlist = new list<cdepartmentinfo> ();
departmentlist = Organizationrule.getlist (Sjid);//read a list class, this is
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=\" column management \ ">" + stropinion);
X.write ("\ r \ n");
Display (AA. Bm_categorylxpm.tostring (). Trim (), Text + space, ref icount,x);
X.write ("</dstree" + AA. Bm_categorylxpm.trim () + ">");
} |
The method is to refer to the online ASP to generate ...