XmlWriter.Create 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
创建新的 XmlWriter 实例。
重载
| 名称 | 说明 |
|---|---|
| Create(StringBuilder, XmlWriterSettings) |
使用XmlWriter和StringBuilder对象创建新XmlWriterSettings实例。 |
| Create(String, XmlWriterSettings) |
使用文件名和XmlWriter对象创建新XmlWriterSettings实例。 |
| Create(TextWriter, XmlWriterSettings) |
使用XmlWriter和TextWriter对象创建新XmlWriterSettings实例。 |
| Create(Stream, XmlWriterSettings) |
使用流和XmlWriter对象创建新XmlWriterSettings实例。 |
| Create(XmlWriter, XmlWriterSettings) |
使用指定XmlWriter对象和XmlWriter对象创建新XmlWriterSettings实例。 |
| Create(StringBuilder) |
使用指定的XmlWriter实例创建一个新StringBuilder实例。 |
| Create(String) |
使用指定的文件名创建新 XmlWriter 实例。 |
| Create(TextWriter) |
使用指定的XmlWriter实例创建一个新TextWriter实例。 |
| Create(Stream) |
使用指定的流创建新 XmlWriter 实例。 |
| Create(XmlWriter) |
注解
某些 Create 重载包括接受 settings 对象的 XmlWriterSettings 参数。 可以使用此对象来:
指定要在创建 XmlWriter 的对象上支持的功能。
重复使用该 XmlWriterSettings 对象来创建多个编写器对象。 将 XmlWriterSettings 为每个创建的编写器复制对象并标记为只读。 对实例上的 XmlWriterSettings 设置的更改不会影响具有相同设置的现有编写器。 因此,可以使用相同的设置创建具有相同功能的多个编写器。 或者,可以修改实例上的 XmlWriterSettings 设置,并使用一组不同的功能创建新的编写器。
向现有 XML 编写器添加功能。 该方法 Create 可以接受另一个 XmlWriter 对象。 基础 XmlWriter 对象不必是静态 Create 方法创建的 XML 编写器。 例如,可以指定要向其添加其他功能的用户定义的 XML 编写器。
充分利用诸如更好地符合性检查和符合 XML 1.0 建议 等功能,这些建议仅适用于 XmlWriter 静态 Create 方法创建的对象。
如果使用 Create 不接受 XmlWriterSettings 对象的重载,则使用以下默认编写器设置:
| 设置 | 默认 |
|---|---|
| CheckCharacters | true |
| CloseOutput | false |
| ConformanceLevel | ConformanceLevel.Document |
| Encoding | Encoding.UTF8 |
| Indent | false |
| IndentChars | 两个空格 |
| NamespaceHandling | Default (无删除) |
| NewLineChars |
\r\n (回车符、非 Unix 平台的换行符)或 \n Unix 平台的(换行符) |
| NewLineHandling | NewLineHandling.Replace |
| NewLineOnAttributes | false |
| OmitXmlDeclaration | false |
| OutputMethod | XmlOutputMethod.Xml |
| WriteEndDocumentOnClose | true |
注释
尽管 .NET Framework 包含 XmlTextWriter 类,这是 XmlWriter 类的具体实现,但我们建议使用 Create 方法创建 XmlWriter 实例。
Create(StringBuilder, XmlWriterSettings)
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
使用XmlWriter和StringBuilder对象创建新XmlWriterSettings实例。
public:
static System::Xml::XmlWriter ^ Create(System::Text::StringBuilder ^ output, System::Xml::XmlWriterSettings ^ settings);
public static System.Xml.XmlWriter Create(System.Text.StringBuilder output, System.Xml.XmlWriterSettings settings);
public static System.Xml.XmlWriter Create(System.Text.StringBuilder output, System.Xml.XmlWriterSettings? settings);
static member Create : System.Text.StringBuilder * System.Xml.XmlWriterSettings -> System.Xml.XmlWriter
Public Shared Function Create (output As StringBuilder, settings As XmlWriterSettings) As XmlWriter
参数
- output
- StringBuilder
StringBuilder要写入到的项。 由该XmlWriter内容追加到 .StringBuilder
- settings
- XmlWriterSettings
XmlWriterSettings用于配置新XmlWriter实例的对象。 如果是,nullXmlWriterSettings则使用默认设置。
XmlWriter如果正与该方法一起使用Transform(String, XmlWriter),则应使用该OutputSettings属性来获取XmlWriterSettings具有正确设置的对象。 这可确保创建的 XmlWriter 对象具有正确的输出设置。
返回
一个 XmlWriter 对象。
例外
output 是 null。
适用于
Create(String, XmlWriterSettings)
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
使用文件名和XmlWriter对象创建新XmlWriterSettings实例。
public:
static System::Xml::XmlWriter ^ Create(System::String ^ outputFileName, System::Xml::XmlWriterSettings ^ settings);
public static System.Xml.XmlWriter Create(string outputFileName, System.Xml.XmlWriterSettings? settings);
public static System.Xml.XmlWriter Create(string outputFileName, System.Xml.XmlWriterSettings settings);
static member Create : string * System.Xml.XmlWriterSettings -> System.Xml.XmlWriter
Public Shared Function Create (outputFileName As String, settings As XmlWriterSettings) As XmlWriter
参数
- outputFileName
- String
要写入的文件。 在 XmlWriter 指定路径处创建一个文件,并在 XML 1.0 文本语法中写入该文件。 必须是 outputFileName 文件系统路径。
- settings
- XmlWriterSettings
XmlWriterSettings用于配置新XmlWriter实例的对象。 如果是,nullXmlWriterSettings则使用默认设置。
XmlWriter如果正与该方法一起使用Transform(String, XmlWriter),则应使用该OutputSettings属性来获取XmlWriterSettings具有正确设置的对象。 这可确保创建的 XmlWriter 对象具有正确的输出设置。
返回
一个 XmlWriter 对象。
例外
outputFileName 是 null。
示例
以下示例使用定义的设置创建一个 XmlWriter 对象。
using System;
using System.IO;
using System.Xml;
using System.Text;
public class Sample {
public static void Main() {
XmlWriter writer = null;
try {
// Create an XmlWriterSettings object with the correct options.
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.IndentChars = ("\t");
settings.OmitXmlDeclaration = true;
// Create the XmlWriter object and write some content.
writer = XmlWriter.Create("data.xml", settings);
writer.WriteStartElement("book");
writer.WriteElementString("item", "tesing");
writer.WriteEndElement();
writer.Flush();
}
finally {
if (writer != null)
writer.Close();
}
}
}
Imports System.IO
Imports System.Xml
Imports System.Text
Public Class Sample
Public Shared Sub Main()
Dim writer As XmlWriter = Nothing
Try
' Create an XmlWriterSettings object with the correct options.
Dim settings As XmlWriterSettings = New XmlWriterSettings()
settings.Indent = true
settings.IndentChars = (ControlChars.Tab)
settings.OmitXmlDeclaration = true
' Create the XmlWriter object and write some content.
writer = XmlWriter.Create("data.xml", settings)
writer.WriteStartElement("book")
writer.WriteElementString("item", "tesing")
writer.WriteEndElement()
writer.Flush()
Finally
If Not (writer Is Nothing) Then
writer.Close()
End If
End Try
End Sub
End Class
适用于
Create(TextWriter, XmlWriterSettings)
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
使用XmlWriter和TextWriter对象创建新XmlWriterSettings实例。
public:
static System::Xml::XmlWriter ^ Create(System::IO::TextWriter ^ output, System::Xml::XmlWriterSettings ^ settings);
public static System.Xml.XmlWriter Create(System.IO.TextWriter output, System.Xml.XmlWriterSettings settings);
public static System.Xml.XmlWriter Create(System.IO.TextWriter output, System.Xml.XmlWriterSettings? settings);
static member Create : System.IO.TextWriter * System.Xml.XmlWriterSettings -> System.Xml.XmlWriter
Public Shared Function Create (output As TextWriter, settings As XmlWriterSettings) As XmlWriter
参数
- output
- TextWriter
TextWriter要写入到的。 写入 XmlWriter XML 1.0 文本语法并将其追加到指定的 TextWriter。
- settings
- XmlWriterSettings
XmlWriterSettings用于配置新XmlWriter实例的对象。 如果是,nullXmlWriterSettings则使用默认设置。
XmlWriter如果正与该方法一起使用Transform(String, XmlWriter),则应使用该OutputSettings属性来获取XmlWriterSettings具有正确设置的对象。 这可确保创建的 XmlWriter 对象具有正确的输出设置。
返回
一个 XmlWriter 对象。
例外
output 是 null。
示例
以下示例写出 XML 字符串。
XmlWriterSettings settings = new XmlWriterSettings();
settings.OmitXmlDeclaration = true;
StringWriter sw = new StringWriter();
using (XmlWriter writer = XmlWriter.Create(sw, settings))
{
writer.WriteStartElement("book");
writer.WriteElementString("price", "19.95");
writer.WriteEndElement();
writer.Flush();
String output = sw.ToString();
}
Dim settings As New XmlWriterSettings()
settings.OmitXmlDeclaration = True
Dim sw As New StringWriter()
Using writer As XmlWriter = XmlWriter.Create(sw, settings)
writer.WriteStartElement("book")
writer.WriteElementString("price", "19.95")
writer.WriteEndElement()
writer.Flush()
Dim output As String = sw.ToString()
End Using
适用于
Create(Stream, XmlWriterSettings)
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
使用流和XmlWriter对象创建新XmlWriterSettings实例。
public:
static System::Xml::XmlWriter ^ Create(System::IO::Stream ^ output, System::Xml::XmlWriterSettings ^ settings);
public static System.Xml.XmlWriter Create(System.IO.Stream output, System.Xml.XmlWriterSettings settings);
public static System.Xml.XmlWriter Create(System.IO.Stream output, System.Xml.XmlWriterSettings? settings);
static member Create : System.IO.Stream * System.Xml.XmlWriterSettings -> System.Xml.XmlWriter
Public Shared Function Create (output As Stream, settings As XmlWriterSettings) As XmlWriter
参数
- settings
- XmlWriterSettings
XmlWriterSettings用于配置新XmlWriter实例的对象。 如果是,nullXmlWriterSettings则使用默认设置。
XmlWriter如果正与该方法一起使用Transform(String, XmlWriter),则应使用该OutputSettings属性来获取XmlWriterSettings具有正确设置的对象。 这可确保创建的 XmlWriter 对象具有正确的输出设置。
返回
一个 XmlWriter 对象。
例外
output 是 null。
示例
以下示例将 XML 片段写入内存流。
XmlWriterSettings settings = new XmlWriterSettings();
settings.OmitXmlDeclaration = true;
settings.ConformanceLevel = ConformanceLevel.Fragment;
settings.CloseOutput = false;
// Create the XmlWriter object and write some content.
MemoryStream strm = new MemoryStream();
XmlWriter writer = XmlWriter.Create(strm, settings);
writer.WriteElementString("orderID", "1-456-ab");
writer.WriteElementString("orderID", "2-36-00a");
writer.Flush();
writer.Close();
// Do additional processing on the stream.
Dim settings As XmlWriterSettings = New XmlWriterSettings()
settings.OmitXmlDeclaration = true
settings.ConformanceLevel = ConformanceLevel.Fragment
settings.CloseOutput = false
' Create the XmlWriter object and write some content.
Dim strm as MemoryStream = new MemoryStream()
Dim writer As XmlWriter = XmlWriter.Create(strm, settings)
writer.WriteElementString("orderID", "1-456-ab")
writer.WriteElementString("orderID", "2-36-00a")
writer.Flush()
writer.Close()
' Do additional processing on the stream.
注解
XmlWriter 始终将字节顺序标记(BOM)写入基础数据流;但是,某些流不得具有 BOM。 若要省略 BOM,请创建一个新 XmlWriterSettings 对象,并将 Encoding 属性设置为具有 UTF8Encoding 构造函数中布尔值的新对象设置为 false。
适用于
Create(XmlWriter, XmlWriterSettings)
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
使用指定XmlWriter对象和XmlWriter对象创建新XmlWriterSettings实例。
public:
static System::Xml::XmlWriter ^ Create(System::Xml::XmlWriter ^ output, System::Xml::XmlWriterSettings ^ settings);
public static System.Xml.XmlWriter Create(System.Xml.XmlWriter output, System.Xml.XmlWriterSettings settings);
public static System.Xml.XmlWriter Create(System.Xml.XmlWriter output, System.Xml.XmlWriterSettings? settings);
static member Create : System.Xml.XmlWriter * System.Xml.XmlWriterSettings -> System.Xml.XmlWriter
Public Shared Function Create (output As XmlWriter, settings As XmlWriterSettings) As XmlWriter
参数
- settings
- XmlWriterSettings
XmlWriterSettings用于配置新XmlWriter实例的对象。 如果是,nullXmlWriterSettings则使用默认设置。
XmlWriter如果正与该方法一起使用Transform(String, XmlWriter),则应使用该OutputSettings属性来获取XmlWriterSettings具有正确设置的对象。 这可确保创建的 XmlWriter 对象具有正确的输出设置。
返回
XmlWriter包装在指定XmlWriter对象周围的对象。
例外
output 是 null。
注解
此方法允许向基础 XmlWriter 对象添加其他功能。 基础 XmlWriter 对象可以是方法 XmlWriter.Create 创建的对象,也可以是使用 XmlTextWriter 实现创建的对象。
适用于
Create(StringBuilder)
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
使用指定的XmlWriter实例创建一个新StringBuilder实例。
public:
static System::Xml::XmlWriter ^ Create(System::Text::StringBuilder ^ output);
public static System.Xml.XmlWriter Create(System.Text.StringBuilder output);
static member Create : System.Text.StringBuilder -> System.Xml.XmlWriter
Public Shared Function Create (output As StringBuilder) As XmlWriter
参数
- output
- StringBuilder
StringBuilder要写入到的项。 由该XmlWriter内容追加到 .StringBuilder
返回
一个 XmlWriter 对象。
例外
output 是 null。
注解
使用此重载时, XmlWriterSettings 将使用具有默认设置的对象来创建 XML 编写器。
| 设置 | 默认 |
|---|---|
| CheckCharacters | true |
| CloseOutput | false |
| ConformanceLevel | ConformanceLevel.Document |
| Encoding | Encoding.UTF8 |
| Indent | false |
| IndentChars | 两个空格 |
| NamespaceHandling | Default (无删除) |
| NewLineChars |
\r\n (回车符、非 Unix 平台的换行符)或 \n Unix 平台的(换行符) |
| NewLineHandling | NewLineHandling.Replace |
| NewLineOnAttributes | false |
| OmitXmlDeclaration | false |
| OutputMethod | XmlOutputMethod.Xml |
| WriteEndDocumentOnClose | true |
如果要指定要在创建的 XML 编写器上支持的功能,请使用一个重载,该重载将对象 XmlWriterSettings 作为其参数之一,并使用自定义设置传入对象 XmlWriterSettings 。
适用于
Create(String)
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
使用指定的文件名创建新 XmlWriter 实例。
public:
static System::Xml::XmlWriter ^ Create(System::String ^ outputFileName);
public static System.Xml.XmlWriter Create(string outputFileName);
static member Create : string -> System.Xml.XmlWriter
Public Shared Function Create (outputFileName As String) As XmlWriter
参数
- outputFileName
- String
要写入的文件。 在 XmlWriter 指定路径处创建一个文件,并在 XML 1.0 文本语法中写入该文件。 必须是 outputFileName 文件系统路径。
返回
一个 XmlWriter 对象。
例外
outputFileName 是 null。
示例
以下示例创建一个 XmlWriter 对象并写入书籍节点。
using (XmlWriter writer = XmlWriter.Create("output.xml"))
{
writer.WriteStartElement("book");
writer.WriteElementString("price", "19.95");
writer.WriteEndElement();
writer.Flush();
}
Using writer As XmlWriter = XmlWriter.Create("output.xml")
writer.WriteStartElement("book")
writer.WriteElementString("price", "19.95")
writer.WriteEndElement()
writer.Flush()
End Using
注解
使用此重载时, XmlWriterSettings 将使用具有默认设置的对象来创建 XML 编写器。
| 设置 | 默认 |
|---|---|
| CheckCharacters | true |
| CloseOutput | false |
| ConformanceLevel | ConformanceLevel.Document |
| Encoding | Encoding.UTF8 |
| Indent | false |
| IndentChars | 两个空格 |
| NamespaceHandling | Default (无删除) |
| NewLineChars |
\r\n (回车符、非 Unix 平台的换行符)或 \n Unix 平台的(换行符) |
| NewLineHandling | NewLineHandling.Replace |
| NewLineOnAttributes | false |
| OmitXmlDeclaration | false |
| OutputMethod | XmlOutputMethod.Xml |
| WriteEndDocumentOnClose | true |
如果要指定要在创建的 XML 编写器上支持的功能,请使用一个重载,该重载将对象 XmlWriterSettings 作为其参数之一,并使用自定义设置传入对象 XmlWriterSettings 。
适用于
Create(TextWriter)
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
使用指定的XmlWriter实例创建一个新TextWriter实例。
public:
static System::Xml::XmlWriter ^ Create(System::IO::TextWriter ^ output);
public static System.Xml.XmlWriter Create(System.IO.TextWriter output);
static member Create : System.IO.TextWriter -> System.Xml.XmlWriter
Public Shared Function Create (output As TextWriter) As XmlWriter
参数
- output
- TextWriter
TextWriter要写入到的。 写入 XmlWriter XML 1.0 文本语法并将其追加到指定的 TextWriter。
返回
一个 XmlWriter 对象。
例外
output 是 null。
示例
以下示例创建输出到控制台的编写器。
using (XmlWriter writer = XmlWriter.Create(Console.Out))
{
writer.WriteStartElement("book");
writer.WriteElementString("price", "19.95");
writer.WriteEndElement();
writer.Flush();
}
Using writer As XmlWriter = XmlWriter.Create(Console.Out)
writer.WriteStartElement("book")
writer.WriteElementString("price", "19.95")
writer.WriteEndElement()
writer.Flush()
End Using
注解
使用此重载时, XmlWriterSettings 将使用具有默认设置的对象来创建 XML 编写器。
| 设置 | 默认 |
|---|---|
| CheckCharacters | true |
| CloseOutput | false |
| ConformanceLevel | ConformanceLevel.Document |
| Encoding | Encoding.UTF8 |
| Indent | false |
| IndentChars | 两个空格 |
| NamespaceHandling | Default (无删除) |
| NewLineChars |
\r\n (回车符、非 Unix 平台的换行符)或 \n Unix 平台的(换行符) |
| NewLineHandling | NewLineHandling.Replace |
| NewLineOnAttributes | false |
| OmitXmlDeclaration | false |
| OutputMethod | XmlOutputMethod.Xml |
| WriteEndDocumentOnClose | true |
如果要指定要在创建编写器上支持的功能,请使用一个重载,该重载采用对象 XmlWriterSettings 作为其参数之一,并使用自定义设置传入对象 XmlWriterSettings 。
适用于
Create(Stream)
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
使用指定的流创建新 XmlWriter 实例。
public:
static System::Xml::XmlWriter ^ Create(System::IO::Stream ^ output);
public static System.Xml.XmlWriter Create(System.IO.Stream output);
static member Create : System.IO.Stream -> System.Xml.XmlWriter
Public Shared Function Create (output As Stream) As XmlWriter
参数
返回
一个 XmlWriter 对象。
例外
output 是 null。
示例
以下示例将 XML 片段写入内存流。 (它使用 Create(Stream, XmlWriterSettings) 重载,该重载还配置新 XML 编写器实例上的设置。
XmlWriterSettings settings = new XmlWriterSettings();
settings.OmitXmlDeclaration = true;
settings.ConformanceLevel = ConformanceLevel.Fragment;
settings.CloseOutput = false;
// Create the XmlWriter object and write some content.
MemoryStream strm = new MemoryStream();
XmlWriter writer = XmlWriter.Create(strm, settings);
writer.WriteElementString("orderID", "1-456-ab");
writer.WriteElementString("orderID", "2-36-00a");
writer.Flush();
writer.Close();
// Do additional processing on the stream.
Dim settings As XmlWriterSettings = New XmlWriterSettings()
settings.OmitXmlDeclaration = true
settings.ConformanceLevel = ConformanceLevel.Fragment
settings.CloseOutput = false
' Create the XmlWriter object and write some content.
Dim strm as MemoryStream = new MemoryStream()
Dim writer As XmlWriter = XmlWriter.Create(strm, settings)
writer.WriteElementString("orderID", "1-456-ab")
writer.WriteElementString("orderID", "2-36-00a")
writer.Flush()
writer.Close()
' Do additional processing on the stream.
注解
使用此重载时, XmlWriterSettings 使用以下默认设置的对象创建 XML 编写器:
| 设置 | 默认 |
|---|---|
| CheckCharacters | true |
| CloseOutput | false |
| ConformanceLevel | ConformanceLevel.Document |
| Encoding | Encoding.UTF8 |
| Indent | false |
| IndentChars | 两个空格 |
| NamespaceHandling | Default (无删除) |
| NewLineChars |
\r\n (回车符、非 Unix 平台的换行符)或 \n Unix 平台的(换行符) |
| NewLineHandling | NewLineHandling.Replace |
| NewLineOnAttributes | false |
| OmitXmlDeclaration | false |
| OutputMethod | XmlOutputMethod.Xml |
| WriteEndDocumentOnClose | true |
如果要指定要在创建编写器上支持的功能,请使用一个重载,该重载采用对象 XmlWriterSettings 作为其参数之一,并使用自定义设置传入对象 XmlWriterSettings 。
此外,XmlWriter 始终将字节顺序标记(BOM)写入基础数据流;但是,某些流不得具有 BOM。 若要省略 BOM,请创建一个新 XmlWriterSettings 对象,并将 Encoding 属性设置为具有 UTF8Encoding 构造函数中布尔值的新对象设置为 false。
适用于
Create(XmlWriter)
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
- Source:
- XmlWriter.cs
public:
static System::Xml::XmlWriter ^ Create(System::Xml::XmlWriter ^ output);
public static System.Xml.XmlWriter Create(System.Xml.XmlWriter output);
static member Create : System.Xml.XmlWriter -> System.Xml.XmlWriter
Public Shared Function Create (output As XmlWriter) As XmlWriter
参数
返回
XmlWriter包装在指定XmlWriter对象周围的对象。
例外
output 是 null。
注解
此方法允许向基础 XmlWriter 对象添加功能。 基础 XmlWriter 对象可以是方法 XmlWriter.Create 创建的对象,也可以是使用 XmlTextWriter 实现创建的对象。
使用此重载时, XmlWriterSettings 将使用具有默认设置的对象来创建 XML 编写器。
| 设置 | 默认 |
|---|---|
| CheckCharacters | true |
| CloseOutput | false |
| ConformanceLevel | ConformanceLevel.Document |
| Encoding | Encoding.UTF8 |
| Indent | false |
| IndentChars | 两个空格 |
| NamespaceHandling | Default (无删除) |
| NewLineChars |
\r\n (回车符、非 Unix 平台的换行符)或 \n Unix 平台的(换行符) |
| NewLineHandling | NewLineHandling.Replace |
| NewLineOnAttributes | false |
| OmitXmlDeclaration | false |
| OutputMethod | XmlOutputMethod.Xml |
| WriteEndDocumentOnClose | true |
如果要指定要在创建的 XML 编写器上支持的功能,请使用一个重载,该重载将对象 XmlWriterSettings 作为其参数之一,并使用自定义设置传入对象 XmlWriterSettings 。