Simple unlimited level tree generates XML code

xiaoxiao2021-03-06  113

????????

Private

?

Void

Makexml

String

? XMLPATH) ????????

{???????????? String? SQLSTR? =? "SELECT? *? from? Tree? ORDER? BY? TREENODE"; ???????????? oledbdataadapter? da ? =? new? oledbdataadapter (sqlstr,? conn); ???????????? DataTable? dt? =? new? DataTable (); ???????????? da .Fill (dt); ???????????? da.dispose ();? ???????????? int? PTREEDEPTH? =? - 1; ????? ??????? int? Treedepth? =? 0; ????????????? xmlTextWriter? xw? =? new? xmlTextWriter (xmlpath,? null); ??????? ????? xw.formatting? =? formatting.indented; ???????????? xw.indentchar? =? ''; ????????????? xw. Indentation? =? 1; ???????????? xw.writestartDocument (); ???????????? xw.writestrtElement ("Treeroot"); ????? ??????? foreach (DATAROW? DR? IN? DT.ROWS) ???????????????????? TreedEPTH? =? Charcount (DR ["Treenode"]. TOSTRING (),? ','); ???????????????? f (treedepth? ==? PTREEDEPTH) ???? ???????????? {???????????????????? xw.writeEndelement (); ??????????? ????????? xw.writestartElement ("treebranch"); ??????????????????????????????????????????????????????????????????????????????????? ? Else? if (treedepth? ==? ptreeDepth? ? 1) ??????????????????????????? ??? xw.writestartelement ("treebranch"); ????????????????????????????????????????????? ?? Else ???????????????? {??????????? for (int? i? =? 0; ? i?

?????????????} ???????????????????????????????

Private

?

Void

? lbmakexml_click

Object

? Sender,? system.eventargs? e) ????????

{???????????? Makexml (Server.MAppath ("Tree.xml")); ????????}

转载请注明原文地址:https://www.9cbs.com/read-125521.html

New Post(0)