The XML file is:
<? XML version = "1.0"?>
<Configuration>
<Configsections>
<Section name = "dataconfiguration" type = "Microsoft. practices. enterpriselibrary. data. configuration. databasesettings, Microsoft. practices. enterpriselibrary. data, version = 3.1.0.0, culture = neutral, publickeytoken = b03f5f7f11d50a3a "/>
</Configsections>
<Connectionstrings>
<Add name = "cnblogsdb" connectionstring = "Data Source = 192.168.0.88; initial catalog = cnblogs; Integrated Security = true" providername = "system. Data. sqlclient"/>
</Connectionstrings>
<Appsettings/>
<System. Web>
<Compilation DEBUG = "false">
<Assemblies>
<Add Assembly = "system. Transactions, version = 2.0.0.0, culture = neutral, publickeytoken = b77a5c561934e089"/>
<Add Assembly = "system. Management, version = 2.0.0.0, culture = neutral, publickeytoken = b03f5f7f11d50a3a"/>
<Add Assembly = "system. Data. oracleclient, version = 2.0.0.0, culture = neutral, publickeytoken = b77a5c561934e089"/>
<Add Assembly = "system. configuration. Install, version = 2.0.0.0, culture = neutral, publickeytoken = b03f5f7f11d50a3a"/>
</Assemblies>
</Compilation>
<Authentication mode = "Windows"/>
</System. Web>
</Configuration>
The. CS file code is:
/*
* Display all content of the XML document on the console using a Tree Structure
*/
Using system;
Using system. Collections. Generic;
Using system. text;
Using system. xml;
Namespace displayxmldemo
{
Class Program
{
Static void main (string [] ARGs)
{
System. xml. xmldocument Doc = new xmldocument ();
// Parse the XML file, which can be obtained through the file name, byte stream, or response stream
Doc. Load (".. \ xmlfile1.xml ");
// Doc. Load (new system. Io. filestream ("http://www.cnblogs.com/xmlfile1.xml ",
// System. Io. filemode. Open ));
// Doc. Load (new system. Io. streamreader ("http://www.cnblogs.com/xmlfile1.xml "));
Shownode (Doc, 0 );
}
Private Static void shownode (xmlnode node, int spacecount)
{
Space (spacecount );
// Output Node itself
Console. writeline ("Name: {0}, type: {1}, value: {2}", node. Name,
Node. nodetype,
Node. value );
// Determine whether the element is used to process the attributes of the element
If (node. nodetype = xmlnodetype. element)
{
Xmlelement element = node as xmlelement;
Foreach (xmlattribute ATT in element. attributes)
{
Shownode (ATT, spacecount + 2 );
}
}
Console. writeline ("-----------------------------------------");
// Process Child Nodes
Foreach (xmlnode N in node. childnodes)
{
Shownode (n, spacecount + 5 );
}
}
Private Static void space (INT count)
{
For (INT I = 0; I <count; I ++)
{
Console. Write (I );
}
}
}
}