读取xml文件
View Code
XmlNode node = this.doc.SelectSingleNode(string.Format("//DXSL//Configuration[@name='{0}']", MailSettings)); XmlNode node2 = node.SelectSingleNode("Server") if (node2 != node) { Server = node2.InnerText; } XmlNodeList list = node.SelectNodes("MailList//Mail"); XmlNodeList list2 = node.SelectNodes("MailList//AppMail"); <Configuration name="MailSettings"> <Server>***</Server> <Port>***</Port> <From>***</From> <Account>***</Account> <Password>***</Password> <MailList> <Mail>***</Mail> <AppMail>***</AppMail> </MailList> <HostServer>VAVChina</HostServer> </Configuration>
View Code
XmlNodeList nodeList = this.doc.SelectNodes(string.Format("//DXSL//Configuration[@name='{0}']//{1}", "Providers", "Provider ")); XmlAttribute attribute1 = nodeList [i].Attributes["name"]; XmlAttribute attribute2 = nodeList [i].Attributes["type"]; XmlAttribute attribute3 = nodeList [i].Attributes["connectionName"]; <Configuration name="Providers"> <Provider name="LogProvider" type="DXSL.EventLog.TextLogWriter,DXSL" /> <Provider name="ErrorLogProvider" type="DXSL.EventLog.TextLogWriter,DXSL" /> <Provider name="ManageProvider" type="MDBLL.Data.MongoDataManage,MDBLL" connectionName="OracleConnectionString" /> </Configuration>