An example of asp.net recursive generation of XML trees

Source: Internet
Author: User
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 ...


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.