如果我要设置:
  <network host="hostname" port="25" userName="[email protected]" password="xxxx"/>
那我要写在哪个节点下面? 
然后要乍么取? 

解决方案 »

  1.   

    没有
    你可以:
        <add key="host" value="hostname"/>
        <add key="port" value="25"/>

    然后
               string host= System.Configuration.ConfigurationSettings.AppSettings.Get("host");
               string port= System.Configuration.ConfigurationSettings.AppSettings.Get("port");
      

  2.   

    加一个appSettings 中
    要在  <appSettings >
        <add key="host" value="hostname"/>
        <add key="port" value="25"/>
       
      </appSettings>
      

  3.   

    在<appSetting></appSetting>中然后<add key="字段" value="      "/
    用System.Configuration.ConfigurationSetting.AppSettings.Get("字段");
      

  4.   

    方法很多:怎样读你google一下:
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <appSettings></appSettings>
      <configSections>
        <section name ="network" type="System.Configuration.NameValueSectionHandler"/>
      </configSections>
      <network>
        <add key="host" value="hostname" />
        <add key="post" value="25" />
        <add key="username" value="aaaa" />
        <add key="password" value="aaaaaa" />
      </network>
    </configuration>
      

  5.   

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <appSettings></appSettings>
      <configSections>
        <section name="network" type="System.Configuration.SingleTagSectionHandler"/>
      </configSections>
      <network host="hostname" post="25" username="test" password="dddddd" />
    </configuration>
      

  6.   

    当然,也可以直接放在appSettings中,也可以配置成: System.Configuration.DictionarySectionHandler,看你个人喜好了。
      

  7.   

    嗯! 谢谢!各位了!上面的给出的我有时间再试试看! 谢谢 !小弟在做XML时试出的一个东西,共享下! 
    一种替换getielementByid 的方法: XmlElement xnl = (XmlElement)xmldom.SelectSingleNode("//*[@ID='port']")
    *表示所有节点! @ID='port'表示属性id=port的第一个节点