# Region traversal XML file call method xmlfileallnodes (server. mappath ("treeout. xml "),"")
/// <Summary>
/// Add the temporary level of the topic
/// </Summary>
Int xmlfileallnodescloumnlvtemp = 0;
/// <Summary>
/// Temporary ID of the added topic
/// </Summary>
Int xmlfileallnodescolumnsidtemp = 0;
/// <Summary>
/// Add a column function
/// </Summary>
/// <Param name = "xmlpath"> XML topic file </param>
/// <Param name = "xmldata"> null "" </param>
/// <! [CDATA [Call method xmlfileallnodes (server. mappath ("treeout. xml"), "")]>
/// <Returns> </returns>
Public String xmlfileallnodes (string xmlpath, string xmldata)
{
System. xml. xmldatadocument myxml = new system. xml. xmldatadocument ();
If (xmldata = "")
{
Myxml. Load (xmlpath); // get XML data
}
Else
{
Myxml. loadxml (xmldata );
}
For (INT I = 0; I <myxml. documentelement. childnodes. Count; I ++)
{
Try
{// Obtain the Tree Structure
If (xmlfileallnodescloumnlvtemp = 0) // Level 1 Node
{
System. web. httpcontext. current. response. write (textdata. estr (xmlfileallnodescloumnlvtemp, "& nbsp;") + xmlfileallnodescolumnsidtemp + myxml. documentelement. childnodes [I]. attributes. getnameditem ("Cont "). value + xmlfileallnodescloumnlvtemp + "<br/> ");
}
Else
{
System. web. httpcontext. current. response. write (textdata. estr (xmlfileallnodescloumnlvtemp, "& nbsp;") + xmlfileallnodescolumnsidtemp + myxml. documentelement. childnodes [I]. attributes. getnameditem ("Cont "). value + xmlfileallnodescloumnlvtemp + "<br/> ");
// If it is a subnode
}
Xmlfileallnodescolumnsidtemp + = 1;
Xmlfileallnodescloumnlvtemp ++;
Xmlfileallnodes (xmlpath, myxml. documentelement. childnodes [I]. outerxml); // obtain all the subnodes in the XML file.
Xmlfileallnodescloumnlvtemp --;
}
Catch (system. xml. xmlexception) // if this is the lowest layer, you will not make the next call.
{
}
}
Return "";
}
# Endregion
XML file
<? XML version = "1.0" encoding = "UTF-8"?>
<Addcolumns>
<Column name = "add topic name 1" Lx = "topic category" dir = "" PIC = "topic image" itempadderss = "topic template address" itempparam = "" tabname =" "Cont =" 'djflksjdlfjl & amp; 1 = & quot; ">
</Column>
</Addcolumns>