zoukankan      html  css  js  c++  java
  • C#中XML使用总结

    XML文件由于格式规范,读写简单,所以非常适宜保存一些程序的配置信息。

    下面总结一下在C#中读写XML文件的方法,随时更新。

    1、获取某个节点的值。

    代码
    XDocument xdoc = XDocument.Load(@"dataConfig.xml");
    this.TB_MMZS.Text = xdoc.Element("Cost").Element("BookInfo").Element("PageWordCount").Value;


    2、查询XML文档。

    代码
    var query = from bookformat in xdoc.Element("Cost").Element("BookInfo").Element("BookFormat").Descendants("BookFormatItem")
                            select bookformat;
                
    foreach (var item in query)
                
    {
                    
    this.DDL_KB.Items.Add(new ListItem(item.Element("Text").Value,item.Element("Value").Value));
                }
  • 相关阅读:
    名词解释
    cwoa2011项目部署到tomcat服务器(环境搭建及项目的运行)
    上网过程与原理
    C-编译器的实现
    css
    HMTL
    FIRST DAY
    关于面试的吐槽
    我的老大去创业啦
    .Net Core下使用 RSA
  • 原文地址:https://www.cnblogs.com/yunfei181/p/1611986.html
Copyright © 2011-2022 走看看