????????
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? ptreedepth? -? treedepth;? i ) ?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ????????? xw.WriteEndelement (); ??????????????????????????? ?????? xw.writendelement (); ???????????????????? xw.writestrtelement ("treebranch"); ????????? ???????} ???????????????? xw.WriteAttributeString ("TreeID",? DR ["TreeID"]. TOSTRING ()); ????? ??????????? xw.writeAttributeString ("Treenode", DR ["Treenode"]. TOSTRING ()); ???????????????? xw. WriteElementString ("Treetitle", DR ["Treetitle"]. TOSTRING ()); ??????????????? ptreedepth? =
?????????????} ??????????????????????????????? =? 0;? i ) ?? ?????????? {????????????????? xw.writeEndelement ();? ????????????} ???? ???????? xw.writendelement (); ???????????? xw.writeEndelement (); ???????????? xw.flush (); ???????????? xw.close (); ????????} ????????
Private
?
Void
? lbmakexml_click
Object
? Sender,? system.eventargs? e) ????????
{???????????? Makexml (Server.MAppath ("Tree.xml")); ????????}