zoukankan      html  css  js  c++  java
  • 创建xml树

    XMLElement 节点
    XMLDocument 节点的CUID操作

    XMLNode 抽象类 操作节点 (XMLElement XMLDocument )

    XElement xElement = new XElement(
    new XElement("BookStore",
    new XElement("Book",
    new XElement("Name", "C#入门", new XAttribute("BookName", "C#")),
    new XElement("Author", "Martin", new XAttribute("Name", "Martin")),
    new XElement("Adress", "上海"),
    new XElement("Date", DateTime.Now.ToString("yyyy-MM-dd"))
    ),
    new XElement("Book",
    new XElement("Name", "WCF入门", new XAttribute("BookName", "WCF")),
    new XElement("Author", "Mary", new XAttribute("Name", "Mary")),
    new XElement("Adress", "北京"),
    new XElement("Date", DateTime.Now.ToString("yyyy-MM-dd"))
    )
    )
    );

    //需要指定编码格式,否则在读取时会抛:根级别上的数据无效。 第 1 行 位置 1异常
    XmlWriterSettings settings = new XmlWriterSettings();
    settings.Encoding = new UTF8Encoding(false);
    settings.Indent = true;
    XmlWriter xw = XmlWriter.Create(xmlPath, settings);
    xElement.Save(xw);
    //写入文件
    xw.Flush();
    xw.Close();

  • 相关阅读:
    Xshell相关优化
    Inotify+rsync远程实时同步
    MySQL主从复制故障解决
    Docker部署centos7容器
    Salt-ssh批量部署minion
    MySQL数据库二
    防火墙2
    MySQl数据库
    防火墙
    http原理2
  • 原文地址:https://www.cnblogs.com/mmbbflyer/p/7715199.html
Copyright © 2011-2022 走看看