zoukankan      html  css  js  c++  java
  • xml 文件读写 c#&C++

    XmlDocument和XDocument
     1         private void button1_Click(object sender, EventArgs e)
     2         {
     3             XmlDocument doc = new XmlDocument();
     4             XmlDeclaration xdc= doc.CreateXmlDeclaration("1.0", "utf-8", null);
     5             XmlElement rootelement = doc.CreateElement("Nodes");
     6             XmlElement ele1 = doc.CreateElement("Node");
     7             ele1.InnerText = "hello";
     8             ele1.SetAttribute("ID", "1");
     9             rootelement.AppendChild(ele1);
    10             doc.AppendChild(xdc);
    11             doc.AppendChild(rootelement);
    12             doc.Save("a.xml");
    13         }
    14 
    15         private void button2_Click(object sender, EventArgs e)
    16         {
    17             XDocument doc = new XDocument(
    18                  new XElement("root",
    19                  new XAttribute("name", "value"),
    20                  new XElement("child", "text node")));
    21             doc.Save("b.xml");
    22         }
  • 相关阅读:
    day4
    day3
    day2
    day1
    结对开发
    开课博客
    个人课程总结
    学习进度条-第八周
    学习进度条-第七周
    Fooks 电梯演讲
  • 原文地址:https://www.cnblogs.com/zhiying678/p/2953682.html
Copyright © 2011-2022 走看看