//设置配置文件物理路径
public string xmlPath = "/manage/spider/config.xml";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//设置程序物理路径+文件物理路径
string path = Request.PhysicalApplicationPath + xmlPath;
//获取XML元素对象
XElement config = XElement.Load(path);
if (config != null)
{
//获得节点子元素
XElement eleAmazonDetailUrl = config.Element("AmazonDetailUrl");
XElement eleAmazonListUrl = config.Element("AmazonListUrl");
XElement eleHz = config.Element("Hz");
XElement eleCount = config.Element("Count");
//在页面上呈现取到的数据
if (eleAmazonDetailUrl != null)
TextBox_AmazonDetailUrl.Text = eleAmazonDetailUrl.Value;
if (eleAmazonListUrl != null)
TextBox_AmazonListUrl.Text = eleAmazonListUrl.Value;
if (eleHz != null)
TextBox_Hz.Text = eleHz.Value;
if (eleCount != null)
TextBox_Count.Text = eleCount.Value;
}
else
Response.Write(""); }
}
protected void btn_Save_Click(object sender, EventArgs e)
{
//设置XML文件路径
string path = Request.PhysicalApplicationPath + xmlPath;
//设置节点的名称和内容
XElement root = new XElement("Settings",
new XElement("AmazonDetailUrl", TextBox_AmazonDetailUrl.Text.Trim()),
new XElement("AmazonListUrl", TextBox_AmazonListUrl.Text.Trim()),
new XElement("Hz", TextBox_Hz.Text.Trim()),
new XElement("Count", TextBox_Count.Text.Trim())
);
//将元素序列化到指定路径的XML文件当中
root.Save(path);
}

最新文章

  1. <<< request.getParameterMap()方法
  2. Designing for iOS: Graphics & Performance
  3. html中frameset的详细使用方法
  4. 设想 Docker 下部署 KVM
  5. CC++初学者编程教程(8) VS2013配置编程助手与QT
  6. ajax使用及代码表示
  7. KEIL中逻辑分析仪的使用
  8. flask-sqlalchemy使用命令创建数据库
  9. c#下载文件选择路径控件
  10. 软件安装配置笔记(一)——Oracle及PLSQL Developer的安装与配置
  11. css学习(1)
  12. Windows 软件推荐大全【all】
  13. 使用Bind搭建DNS服务
  14. Ubuntu 下Apache安装和配置
  15. 显示器如何显示一个YUV422格式的图形
  16. HttpWebRequest和WebClient的用法
  17. mysql 主从复制原理(转)
  18. [9] 圆环(Ring)图形的生成算法
  19. EL运算符(web基础学习笔记十七)
  20. cxf之Exception in thread "main" java.lang.NoSuchMethodError: org.apache.cxf.jaxrs.provider.ProviderFactory.<init>(Lorg/apache/cxf/Bus;)V

热门文章

  1. 使用SSH代理上IPV6(使用SSH端口转发)
  2. c#语句 (随堂练习)
  3. 【HDOJ】2371 Decode the Strings
  4. C 函数原型
  5. Light OJ 1025 - The Specials Menu(区间DP)
  6. 动态规划(水题):COGS 261. [NOI1997] 积木游戏
  7. zookeeper集群环境安装配置
  8. 数据结构典型算法的VC实现(袁辉勇)
  9. jMeter接口测试案例
  10. 在eclipse下远程调试hadoop2.0