C # Parsing XML file code instance sharing
XmlNodeReader reader = null; try {XmlDocument xd = new XmlDocument (); Xd. Load (filename); reader = new XmlNodeReader (XD); Create a new XML reader string nodeType = null; while (reader. Read ()) {switch (reader). NodeType) {Case xmlnodetype.element://determines if the read is a node n Odetype = reader. Name; Break Case XMLNODETYPE.TEXT://Determines if the read is a node value of switch (nodeType) { Case root:rootvalue = reader. Value; Break Default:break; } break; Default:break; }}} catch (Exception e) {System.Console.WriteLine ("Read XML File Error: "+ e.message + e.stacktrace); } finally {if (reader! = null) {reader. Close (); } }...................... Finally, don't forget to close the reader.
This method can actually be used to reduce the number of command line arguments, now only need to add a file name. But to write the parameters in the file