读取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>

 

posted @ 2013-02-21 12:28  石 磊  阅读(325)  评论(0编辑  收藏  举报