1. Some specific  name: XmlDocument XmlNodeList XmlNode XmlElement
    The whole architecture and relation among them is following
    Attentions:selectsinglenodelist(”users”),用于获取users下面的所有直接子节点。这个方法经常用到
2. the difference between xmlnode and xmlelement
    XmlElement从XmlNode继承而来,功能基本相同,但XmlElement有更多的功能   
 3. Insert data into XML file sample:
  Sample 1:
  XmlDocument xdoc = new XmlDocument();
        xdoc.Load(HttpContext.Current.Server.MapPath("user.config"));

XmlElement xde = xdoc.DocumentElement;
        XmlElement xe = xdoc.CreateElement("user");
        xe.SetAttribute("Login", login);
        xe.SetAttribute("Password", pwd);
        xe.SetAttribute("RootFolder", rootfolder);
        xe.SetAttribute("Rights", rights);
        xde.AppendChild(xe);
        xdoc.Save(HttpContext.Current.Server.MapPath("user.config"));
the xml file is the following
<?xml version="1.0" standalone="yes"?>
<users>
  <user Login="sanxumei" Password="sanxumei" RootFolder="c:\inetpub\wwroot" Rights="User" />
</users>

Sample 2:
XmlDocument xmlDoc=new XmlDocument();
   xmlDoc.Load("bookstore.xml");
   XmlNode root=xmlDoc.SelectSingleNode("bookstore");//查找<bookstore>
   XmlElement xe1=xmlDoc.CreateElement("book");//创建一个<book>节点
   xe1.SetAttribute("genre","李赞红");//设置该节点genre属性
   xe1.SetAttribute("ISBN","2-3631-4");//设置该节点ISBN属性
 
   XmlElement xesub1=xmlDoc.CreateElement("title");
   xesub1.InnerText="CS从入门到精通";//设置文本节点
   xe1.AppendChild(xesub1);//添加到<book>节点中
   XmlElement xesub2=xmlDoc.CreateElement("author");
   xesub2.InnerText="候捷";
   xe1.AppendChild(xesub2);
   XmlElement xesub3=xmlDoc.CreateElement("price");
   xesub3.InnerText="58.3";
   xe1.AppendChild(xesub3);
 
   root.AppendChild(xe1);//添加到<bookstore>节点中
   xmlDoc.Save("bookstore.xml");

转载于:https://www.cnblogs.com/Winston/archive/2008/01/04/1026475.html

operate XML file (Open,Insert)相关推荐

  1. Binary XML file line #8: Error inflating class android.support.v7.widget.RecyclerView

    今天创建了一个 demo ,然后就是复制RecyclerView 过去, 到最后完成运行的时候发现 系统奔溃了, 然后 提示 Binary XML file line #8: Error inflat ...

  2. Android运行时候报错:android.view.InflateException: Binary XML file line #19: Binary XML file lin

    Android运行时候报错:android.view.InflateException: Binary XML file line #19: Binary XML file lin 这个问题自己大致在 ...

  3. android.view.InflateException: Binary XML file line #7: Binary XML file line #7

    错误如下 11-21 08:19:44.040 3608-3608/com.leon.oldrecyclerview E/AndroidRuntime: FATAL EXCEPTION: main   ...

  4. android Binary XML file line #1: Binary XML file line #1: Error inflating class x 问题详解

    话不多少,上错误堆栈: Process: com.mci.smagazine, PID: 25065java.lang.RuntimeException: Unable to start activi ...

  5. 报错android.view.InflateException: Binary XML file line #11: Attempt to invoke virtual method 'boolean

    出现这种问题,打开Android monitor的调试信息发现是 android.view.InflateException: Binary XML file line #11: Attempt to ...

  6. 安卓(android)建立项目时失败,出现Android Manifest.xml file missing几种解决方法?...

    安卓(android)建立项目时失败,出现AndroidManifest.xml file missing几种解决方法? Eclipse新建项目,遇到这样的问题,注意如下: 1.文件名最好不要用中文. ...

  7. UI Automator Viewer Error while obtaining UI hierarchy XML file

    Error obtaining UI hierarchy Reason: Error while obtaining UI hierarchy XML file: com.android.ddmlib ...

  8. Android --- Binary XML file line2 Binary XML file line 2 Error inflating class unknown

    报错信息如下: 05/21 10:18:21: Launching app $ adb push D:\android install files\jishi\app\build\outputs\ap ...

  9. XML file does not appear to have any style information associated with it. XHTML程序出现这个错误

    编写xhtml代码出现错误: This XML file does not appear to have any style information associated with it. The d ...

最新文章

  1. hbuildx打包成apk_HBuilder打包webapp为apk的方法
  2. P1063 能量项链
  3. wxWidgets:wxInitDialogEvent类用法
  4. 06.QT菜单栏QAction学习(二)
  5. 记录——《C Primer Plus (第五版)》第十章编程练习第八题
  6. 搭建dubbo框架的遇到的一些问题
  7. UiPath安装pdf
  8. WES7 定制界面完整过程
  9. HTML5生日快乐代码 (烟花蛋糕+3D相册) HTML+CSS+JavaScript
  10. matlab分析电路,基于Matlab的电路节点分析法
  11. 微电子电路——PMOS网表详解
  12. 如何对待新事物_以积极态度看待不断出现的新事物
  13. selenium自动化之PO模型
  14. [转]技术经纪人将成职业新宠
  15. ExoPlayer修改播放器UI
  16. FreeMarker的基础操作
  17. 各种智能优化算法比较与实现(matlab版)
  18. 妈,别再乱买保健品了!
  19. Outlook Express邮件丢失的原因
  20. JAVA电影院管理系统计算机毕业设计Mybatis+系统+数据库+调试部署

热门文章

  1. 程序员节,10月24日!
  2. 禅道项目管理软件的命令行入口
  3. MATLAB的iptcheckinput函数详解
  4. leetcode算法题--构建乘积数组
  5. c# 获取cad文档的路径_C# 打开以对话框,获取文件夹路径 、文件的路径、文件名...
  6. 2019值得每天闲逛的网站
  7. 《Java从小白到大牛》之第9章 字符串
  8. Yii2中关于组件的注册以及创建的方法详解
  9. Windows Server 2008 之 终端服务TS WEB ACCESS
  10. h264 流、帧结构