zoukankan      html  css  js  c++  java
  • C# XML读取修改操作

    XML 读取修改操作。
     读取
    XmlTextReader textReader = new XmlTextReader(Server.MapPath( "mb_Msg.xml"));
                                    textReader.Read();
                                     while (textReader.Read())
                                    {
                                                    textReader.MoveToElement();
                                                     if (textReader.Name == "msg" )
                                                    {
                                                                    content.Text = textReader.ReadString();
     
                                                    }
                                    }
                                    textReader.Close();
     
     
     
     
     
    修改:
     XmlDocument xml = new XmlDocument();
            xml.Load(Server.MapPath("YG_msg.xml"));
            XmlNode msg = xml.SelectSingleNode("/root/msg");
            msg.InnerText = getstring(Request.Form["content"]);
            XmlNode user = xml.SelectSingleNode("/root/user");
            user.InnerText = getstring(Request.Form["fn_userName"]);
            XmlNode pwd = xml.SelectSingleNode("/root/pwd");
            if (getstring(Request.Form["fn_userPwd"]).Trim() != string.Empty)
            {
                pwd.InnerText = getstring(Request.Form["fn_userPwd"]);
            }
            xml.Save(Server.MapPath("YG_msg.xml"));
            FormBase.showmsg("设置成功", "success", "", "closewin('winmsg');", this);
     
     
     
     
    xml:(name='mb_Msg.xml')
    <?xml version=" 1.0" encoding=" utf-8" ?>
    <root>
      <msg> xm 您好,这是一条回访信息,请勿回复!
      </msg>
    </root>
  • 相关阅读:
    go相关
    mac下使用vscode技巧
    mac下secureCRT的使用技巧
    python subprocess实时输出
    python中多级目录导入模块问题
    python的print与sys.stdout
    python中类相关笔记
    python中sys.stdout.flush()的作用
    nginx+uwsgi配置
    虚拟机的 基本配置
  • 原文地址:https://www.cnblogs.com/BungeeJumping/p/3384311.html
Copyright © 2011-2022 走看看