将数据库写入xml文件

时间:2015-09-10 08:51:35

标签: c# xml utf-8 xmlwriter

  1. 如何将数据库导出为格式为utf-8的.xml文件,因为我的格式为utf-8 BOM但我需要它没有BOM
  2. 创建我的xml文件的代码是:

    if (saveFileDialog1.ShowDialog() == DialogResult.OK)
    {
        XmlWriterSettings settings = new XmlWriterSettings();
        settings.Encoding = Encoding.UTF8;
        settings.Indent = true;
        settings.NewLineOnAttributes = true;
        using (XmlWriter xmlWriter = XmlWriter.Create(saveFileDialog1.FileName, settings))
        {
            dt.WriteXml(xmlWriter);
            xmlWriter.Close();
        }
    }
    
    1. 在我创建的.xml的第一行,格式写为“utf-8”,但我需要它而不是“ - ”,我只需要“utf8”
    2. this is the created .xml file (the left side is how it should be and the right side is my created xml file

      1. 在第一行中,如何将DocumentElement更改为table name = "UnknownTable"

0 个答案:

没有答案