C # read XML documentation

zhaozj2021-02-17  55

Here is a method of reading an XML document. If which bit is a better method, you can communicate.

The XMLTextReader function is used in the example, and each execution read () once, read a line.

USING SYSTEM.XML;

public KSBMCONFIG ReadConfig (string XmlConfigFile) {KSBMCONFIG _conf = new KSBMCONFIG (); try {// Open an XML file System.Xml.XmlTextReader reader; reader = new System.Xml.XmlTextReader (XmlConfigFile); while (reader.Read () ) {IF (Reader.NodeTelement) && (Reader.Name == "ksbm")) {Break;} if (Reader.IstartElement ("ServerPath")) {Reader.Read (); _conf. ServerPath = Reader.Value;} else if ("smtpserver")) {reader.read (); _conf.smtpserver = reader.value;} else f (Reader.IstartElement ("ConnectString)) {Reader. Read (); _Conf.connectString = Reader.Value;}} Return_conf;} catch {_conf.connectstring = "; _conf.serverPath ="; _conf.smtpserver = "; returnif;} finally {}}

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

New Post(0)