国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

.Net操作XML文件

2019-11-17 01:26:59
字體:
來源:轉載
供稿:網友
.Net操作xml文件

 1  //設置配置文件物理路徑 2     public string xmlPath = "/manage/spider/config.xml"; 3     PRotected void Page_Load(object sender, EventArgs e) 4     { 5         if (!IsPostBack) 6         { 7             //設置程序物理路徑+文件物理路徑 8             string path = Request.PhysicalapplicationPath + xmlPath; 9             //獲取XML元素對象10             XElement config = XElement.Load(path);11             if (config != null)12             {13                 //獲得節點子元素14                 XElement eleAmazonDetailUrl = config.Element("AmazonDetailUrl");15                 XElement eleAmazonListUrl = config.Element("AmazonListUrl");16                 XElement eleHz = config.Element("Hz");17                 XElement eleCount = config.Element("Count");18                 //在頁面上呈現取到的數據19                 if (eleAmazonDetailUrl != null)20                     TextBox_AmazonDetailUrl.Text = eleAmazonDetailUrl.Value;21                 if (eleAmazonListUrl != null)22                     TextBox_AmazonListUrl.Text = eleAmazonListUrl.Value;23                 if (eleHz != null)24                     TextBox_Hz.Text = eleHz.Value;25                 if (eleCount != null)26                     TextBox_Count.Text = eleCount.Value;27             }28             else29                 Response.Write("");30 31         }32     }33     protected void btn_Save_Click(object sender, EventArgs e)34     {35         //設置XML文件路徑36         string path = Request.PhysicalApplicationPath + xmlPath;37         //設置節點的名稱和內容38         XElement root = new XElement("Settings",39              new XElement("AmazonDetailUrl", TextBox_AmazonDetailUrl.Text.Trim()),40              new XElement("AmazonListUrl", TextBox_AmazonListUrl.Text.Trim()),41              new XElement("Hz", TextBox_Hz.Text.Trim()),42              new XElement("Count", TextBox_Count.Text.Trim())43                  );44         //將元素序列化到指定路徑的XML文件當中45         root.Save(path);46      }


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 大名县| 德清县| 易门县| 上饶市| 剑河县| 青浦区| 临安市| 尉氏县| 巍山| 汝南县| 乐昌市| 玛曲县| 万全县| 日喀则市| 塔城市| 邹城市| 耒阳市| 洮南市| 东辽县| 德昌县| 霍邱县| 永安市| 平邑县| 大冶市| 错那县| 阿图什市| 沧源| 定安县| 淮阳县| 邓州市| 齐齐哈尔市| 昭通市| 宁化县| 曲靖市| 防城港市| 临高县| 洪湖市| 泌阳县| 天祝| 库尔勒市| 大英县|