XmlWriter.Create メソッド

定義

新しい 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)

指定したXmlWriter オブジェクトを使用して、新しいXmlWriter インスタンスを作成します。

注釈

一部のCreateオーバーロードには、settings オブジェクトを受け入れるXmlWriterSettings パラメーターが含まれています。 このオブジェクトを使用すると、次のことができます。

  • 作成した XmlWriter オブジェクトでサポートする機能を指定します。

  • XmlWriterSettings オブジェクトを再利用して、複数のライター オブジェクトを作成します。 XmlWriterSettings オブジェクトがコピーされ、作成されたライターごとに読み取り専用としてマークされます。 XmlWriterSettings インスタンスの設定に対する変更は、同じ設定を持つ既存のライターには影響しません。 したがって、同じ設定を使用して、同じ機能を持つ複数のライターを作成できます。 または、 XmlWriterSettings インスタンスの設定を変更し、別の機能セットを使用して新しいライターを作成することもできます。

  • 既存の XML ライターに機能を追加します。 Create メソッドは、別のXmlWriter オブジェクトを受け入れることもできます。 基になる XmlWriter オブジェクトは、静的 Create メソッドによって作成された XML ライターである必要はありません。 たとえば、追加機能を追加するユーザー定義 XML ライターを指定できます。

  • 静的メソッドによって作成されたXmlWriterオブジェクトでのみ使用できる Createに対する準拠チェックやコンプライアンスの向上などの機能を最大限に活用します。

Create オブジェクトを受け入れないXmlWriterSettings オーバーロードを使用する場合は、次の既定のライター設定が使用されます。

Setting デフォルト
CheckCharacters true
CloseOutput false
ConformanceLevel ConformanceLevel.Document
Encoding Encoding.UTF8
Indent false
IndentChars 2 つのスペース
NamespaceHandling Default (削除なし)
NewLineChars \r\n Unix 以外のプラットフォームの場合はキャリッジ リターン、ライン フィード、Unix プラットフォームの場合は \n (ライン フィード)
NewLineHandling NewLineHandling.Replace
NewLineOnAttributes false
OmitXmlDeclaration false
OutputMethod XmlOutputMethod.Xml
WriteEndDocumentOnClose true

Note

.NET Framework には、XmlWriter クラスの具象実装である XmlTextWriter クラスが含まれていますが、Create メソッドを使用して XmlWriter インスタンスを作成することをお勧めします。

Create(StringBuilder, XmlWriterSettings)

ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
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

書き込み先の StringBuilderXmlWriterによって書き込まれたコンテンツは、StringBuilderに追加されます。

settings
XmlWriterSettings

新しいXmlWriterSettings インスタンスの構成に使用するXmlWriter オブジェクト。 これが nullの場合は、既定の設定の XmlWriterSettings が使用されます。

XmlWriterTransform(String, XmlWriter) メソッドで使用されている場合は、OutputSettings プロパティを使用して、正しい設定のXmlWriterSettings オブジェクトを取得する必要があります。 これにより、作成された XmlWriter オブジェクトに正しい出力設定が設定されます。

返品

XmlWriter オブジェクト。

例外

outputnullです。

適用対象

Create(String, XmlWriterSettings)

ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
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 オブジェクト。 これが nullの場合は、既定の設定の XmlWriterSettings が使用されます。

XmlWriterTransform(String, XmlWriter) メソッドで使用されている場合は、OutputSettings プロパティを使用して、正しい設定のXmlWriterSettings オブジェクトを取得する必要があります。 これにより、作成された XmlWriter オブジェクトに正しい出力設定が設定されます。

返品

XmlWriter オブジェクト。

例外

outputFileNamenullです。

次の例では、定義された設定を使用して 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)

ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
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

書き込む TextWriterXmlWriterは XML 1.0 テキスト構文を書き込み、指定したTextWriterに追加します。

settings
XmlWriterSettings

新しいXmlWriterSettings インスタンスの構成に使用するXmlWriter オブジェクト。 これが nullの場合は、既定の設定の XmlWriterSettings が使用されます。

XmlWriterTransform(String, XmlWriter) メソッドで使用されている場合は、OutputSettings プロパティを使用して、正しい設定のXmlWriterSettings オブジェクトを取得する必要があります。 これにより、作成された XmlWriter オブジェクトに正しい出力設定が設定されます。

返品

XmlWriter オブジェクト。

例外

outputnullです。

次の例では、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)

ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
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

パラメーター

output
Stream

書き込むストリーム。 XmlWriterは XML 1.0 テキスト構文を書き込み、指定したストリームに追加します。

settings
XmlWriterSettings

新しいXmlWriterSettings インスタンスの構成に使用するXmlWriter オブジェクト。 これが nullの場合は、既定の設定の XmlWriterSettings が使用されます。

XmlWriterTransform(String, XmlWriter) メソッドで使用されている場合は、OutputSettings プロパティを使用して、正しい設定のXmlWriterSettings オブジェクトを取得する必要があります。 これにより、作成された XmlWriter オブジェクトに正しい出力設定が設定されます。

返品

XmlWriter オブジェクト。

例外

outputnullです。

次の例では、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)

ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
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

パラメーター

output
XmlWriter

基になるライターとして使用する XmlWriter オブジェクト。

settings
XmlWriterSettings

新しいXmlWriterSettings インスタンスの構成に使用するXmlWriter オブジェクト。 これが nullの場合は、既定の設定の XmlWriterSettings が使用されます。

XmlWriterTransform(String, XmlWriter) メソッドで使用されている場合は、OutputSettings プロパティを使用して、正しい設定のXmlWriterSettings オブジェクトを取得する必要があります。 これにより、作成された XmlWriter オブジェクトに正しい出力設定が設定されます。

返品

指定したXmlWriter オブジェクトの周囲にラップされるXmlWriter オブジェクト。

例外

outputnullです。

注釈

このメソッドを使用すると、基になる XmlWriter オブジェクトに追加の機能を追加できます。 基になる XmlWriter オブジェクトには、 XmlWriter.Create メソッドによって作成されたオブジェクト、または XmlTextWriter 実装を使用して作成されたオブジェクトを指定できます。

適用対象

Create(StringBuilder)

ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
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

書き込み先の StringBuilderXmlWriterによって書き込まれたコンテンツは、StringBuilderに追加されます。

返品

XmlWriter オブジェクト。

例外

outputnullです。

注釈

このオーバーロードを使用すると、XML ライターを作成するために、既定の設定を持つ XmlWriterSettings オブジェクトが使用されます。

Setting デフォルト
CheckCharacters true
CloseOutput false
ConformanceLevel ConformanceLevel.Document
Encoding Encoding.UTF8
Indent false
IndentChars 2 つのスペース
NamespaceHandling Default (削除なし)
NewLineChars \r\n Unix 以外のプラットフォームの場合はキャリッジ リターン、ライン フィード、Unix プラットフォームの場合は \n (ライン フィード)
NewLineHandling NewLineHandling.Replace
NewLineOnAttributes false
OmitXmlDeclaration false
OutputMethod XmlOutputMethod.Xml
WriteEndDocumentOnClose true

作成した XML ライターでサポートする機能を指定する場合は、 XmlWriterSettings オブジェクトを引数の 1 つとして受け取り、カスタム設定で XmlWriterSettings オブジェクトを渡すオーバーロードを使用します。

適用対象

Create(String)

ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
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 オブジェクト。

例外

outputFileNamenullです。

次の例では、 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

注釈

このオーバーロードを使用すると、XML ライターを作成するために、既定の設定を持つ XmlWriterSettings オブジェクトが使用されます。

Setting デフォルト
CheckCharacters true
CloseOutput false
ConformanceLevel ConformanceLevel.Document
Encoding Encoding.UTF8
Indent false
IndentChars 2 つのスペース
NamespaceHandling Default (削除なし)
NewLineChars \r\n Unix 以外のプラットフォームの場合はキャリッジ リターン、ライン フィード、Unix プラットフォームの場合は \n (ライン フィード)
NewLineHandling NewLineHandling.Replace
NewLineOnAttributes false
OmitXmlDeclaration false
OutputMethod XmlOutputMethod.Xml
WriteEndDocumentOnClose true

作成した XML ライターでサポートする機能を指定する場合は、 XmlWriterSettings オブジェクトを引数の 1 つとして受け取り、カスタム設定で XmlWriterSettings オブジェクトを渡すオーバーロードを使用します。

適用対象

Create(TextWriter)

ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
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

書き込む TextWriterXmlWriterは XML 1.0 テキスト構文を書き込み、指定したTextWriterに追加します。

返品

XmlWriter オブジェクト。

例外

outputnullです。

次の例では、コンソールに出力するライターを作成します。

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

注釈

このオーバーロードを使用すると、XML ライターを作成するために、既定の設定を持つ XmlWriterSettings オブジェクトが使用されます。

Setting デフォルト
CheckCharacters true
CloseOutput false
ConformanceLevel ConformanceLevel.Document
Encoding Encoding.UTF8
Indent false
IndentChars 2 つのスペース
NamespaceHandling Default (削除なし)
NewLineChars \r\n Unix 以外のプラットフォームの場合はキャリッジ リターン、ライン フィード、Unix プラットフォームの場合は \n (ライン フィード)
NewLineHandling NewLineHandling.Replace
NewLineOnAttributes false
OmitXmlDeclaration false
OutputMethod XmlOutputMethod.Xml
WriteEndDocumentOnClose true

作成したライターでサポートする機能を指定する場合は、 XmlWriterSettings オブジェクトを引数の 1 つとして受け取り、カスタム設定で XmlWriterSettings オブジェクトを渡すオーバーロードを使用します。

適用対象

Create(Stream)

ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
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

パラメーター

output
Stream

書き込むストリーム。 XmlWriterは XML 1.0 テキスト構文を書き込み、指定したストリームに追加します。

返品

XmlWriter オブジェクト。

例外

outputnullです。

次の例では、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.

注釈

このオーバーロードを使用すると、XML ライターを作成するために、次の既定の設定を持つ XmlWriterSettings オブジェクトが使用されます。

Setting デフォルト
CheckCharacters true
CloseOutput false
ConformanceLevel ConformanceLevel.Document
Encoding Encoding.UTF8
Indent false
IndentChars 2 つのスペース
NamespaceHandling Default (削除なし)
NewLineChars \r\n Unix 以外のプラットフォームの場合はキャリッジ リターン、ライン フィード、Unix プラットフォームの場合は \n (ライン フィード)
NewLineHandling NewLineHandling.Replace
NewLineOnAttributes false
OmitXmlDeclaration false
OutputMethod XmlOutputMethod.Xml
WriteEndDocumentOnClose true

作成したライターでサポートする機能を指定する場合は、 XmlWriterSettings オブジェクトを引数の 1 つとして受け取り、カスタム設定で XmlWriterSettings オブジェクトを渡すオーバーロードを使用します。

また、XmlWriter は常に、基になるデータ ストリームにバイトオーダー マーク (BOM) を書き込みます。ただし、一部のストリームには BOM を含めてはなりません。 BOM を省略するには、新しい XmlWriterSettings オブジェクトを作成し、Encoding プロパティを新しい UTF8Encoding オブジェクトに設定し、コンストラクターのブール値を false に設定します。

適用対象

Create(XmlWriter)

ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
XmlWriter.cs
ソース:
XmlWriter.cs

指定したXmlWriter オブジェクトを使用して、新しいXmlWriter インスタンスを作成します。

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

パラメーター

output
XmlWriter

基になるライターとして使用する XmlWriter オブジェクト。

返品

指定したXmlWriter オブジェクトの周囲にラップされるXmlWriter オブジェクト。

例外

outputnullです。

注釈

このメソッドを使用すると、基になる XmlWriter オブジェクトに特徴を追加できます。 基になる XmlWriter オブジェクトには、 XmlWriter.Create メソッドによって作成されたオブジェクト、または XmlTextWriter 実装を使用して作成されたオブジェクトを指定できます。

このオーバーロードを使用すると、XML ライターを作成するために、既定の設定を持つ XmlWriterSettings オブジェクトが使用されます。

Setting デフォルト
CheckCharacters true
CloseOutput false
ConformanceLevel ConformanceLevel.Document
Encoding Encoding.UTF8
Indent false
IndentChars 2 つのスペース
NamespaceHandling Default (削除なし)
NewLineChars \r\n Unix 以外のプラットフォームの場合はキャリッジ リターン、ライン フィード、Unix プラットフォームの場合は \n (ライン フィード)
NewLineHandling NewLineHandling.Replace
NewLineOnAttributes false
OmitXmlDeclaration false
OutputMethod XmlOutputMethod.Xml
WriteEndDocumentOnClose true

作成した XML ライターでサポートする機能を指定する場合は、 XmlWriterSettings オブジェクトを引数の 1 つとして受け取り、カスタム設定で XmlWriterSettings オブジェクトを渡すオーバーロードを使用します。

適用対象