zoukankan      html  css  js  c++  java
  • xml写入

                XmlDocument xmlDocument=new XmlDocument();
                        XmlElement root = xmlDocument.CreateElement("", "root", "");
                        xmlDocument.AppendChild(root);
                        XmlNode rootnode = xmlDocument.SelectSingleNode("root");
                        for (int i = 0; i < table.Rows.Count; i++)
                        {
                            XmlElement item = xmlDocument.CreateElement("item");
                            item.SetAttribute("number", table.Rows[i]["number"].ToString());
                            item.SetAttribute("name", table.Rows[i]["name"].ToString());
                            item.SetAttribute("specification", table.Rows[i]["specification"].ToString());
                            item.SetAttribute("comments", table.Rows[i]["comments"].ToString());
                            root.AppendChild(item);
                        }
                        string xmlstr = xmlDocument.InnerXml;

     以上是C# xml的写入方法,从数据库表读取的数据,写入xml中,保存为字符串格式。

  • 相关阅读:
    leetcode 137
    leetcode 134
    133. Clone Graph
    leetcode 131
    leetcode 130
    mac uwsgi ssl issue handler
    leetcode 85 Maximal Rectangle golang
    leetcode 84 golang
    leetcode 61
    C# 后台实现一次上传多个文件
  • 原文地址:https://www.cnblogs.com/liuchenxing/p/9050593.html
Copyright © 2011-2022 走看看