XmlWriter.Create XmlWriter.Create XmlWriter.Create XmlWriter.Create Method

정의

XmlWriter 인스턴스를 만듭니다.Creates a new XmlWriter instance.

오버로드

Create(XmlWriter, XmlWriterSettings) Create(XmlWriter, XmlWriterSettings) Create(XmlWriter, XmlWriterSettings) Create(XmlWriter, XmlWriterSettings)

지정된 XmlWriterXmlWriter 개체를 사용하여 새 XmlWriterSettings 인스턴스를 만듭니다.Creates a new XmlWriter instance using the specified XmlWriter and XmlWriterSettings objects.

Create(String, XmlWriterSettings) Create(String, XmlWriterSettings) Create(String, XmlWriterSettings) Create(String, XmlWriterSettings)

파일 이름과 XmlWriter 개체를 사용하여 새 XmlWriterSettings 인스턴스를 만듭니다.Creates a new XmlWriter instance using the filename and XmlWriterSettings object.

Create(TextWriter, XmlWriterSettings) Create(TextWriter, XmlWriterSettings) Create(TextWriter, XmlWriterSettings) Create(TextWriter, XmlWriterSettings)

XmlWriterTextWriter 개체를 사용하여 새 XmlWriterSettings 인스턴스를 만듭니다.Creates a new XmlWriter instance using the TextWriter and XmlWriterSettings objects.

Create(Stream, XmlWriterSettings) Create(Stream, XmlWriterSettings) Create(Stream, XmlWriterSettings) Create(Stream, XmlWriterSettings)

스트림과 XmlWriter 개체를 사용하여 새 XmlWriterSettings 인스턴스를 만듭니다.Creates a new XmlWriter instance using the stream and XmlWriterSettings object.

Create(StringBuilder, XmlWriterSettings) Create(StringBuilder, XmlWriterSettings) Create(StringBuilder, XmlWriterSettings) Create(StringBuilder, XmlWriterSettings)

XmlWriterStringBuilder 개체를 사용하여 새 XmlWriterSettings 인스턴스를 만듭니다.Creates a new XmlWriter instance using the StringBuilder and XmlWriterSettings objects.

Create(StringBuilder) Create(StringBuilder) Create(StringBuilder) Create(StringBuilder)

지정된 XmlWriter를 사용하여 새 StringBuilder 인스턴스를 만듭니다.Creates a new XmlWriter instance using the specified StringBuilder.

Create(String) Create(String) Create(String) Create(String)

지정된 파일 이름을 사용하여 새 XmlWriter 인스턴스를 만듭니다.Creates a new XmlWriter instance using the specified filename.

Create(TextWriter) Create(TextWriter) Create(TextWriter) Create(TextWriter)

지정된 XmlWriter를 사용하여 새 TextWriter 인스턴스를 만듭니다.Creates a new XmlWriter instance using the specified TextWriter.

Create(Stream) Create(Stream) Create(Stream) Create(Stream)

지정된 스트림을 사용하여 새 XmlWriter 인스턴스를 만듭니다.Creates a new XmlWriter instance using the specified stream.

Create(XmlWriter) Create(XmlWriter) Create(XmlWriter) Create(XmlWriter)

지정된 XmlWriter 개체를 사용하여 새 XmlWriter 인스턴스를 만듭니다.Creates a new XmlWriter instance using the specified XmlWriter object.

설명

일부를 Create 오버 로드 포함을 settings 허용 하는 매개 변수는 XmlWriterSettings 개체입니다.Some of the Create overloads include a settings parameter that accepts an XmlWriterSettings object. 이 개체를 사용할 수 있습니다.You can use this object to:

  • 만들어진 지원 하려는 기능 지정 XmlWriter 개체입니다.Specify which features you want supported on the created XmlWriter object.

  • 재사용을 XmlWriterSettings 여러 작성기 개체를 만들 개체입니다.Reuse the XmlWriterSettings object to create multiple writer objects. XmlWriterSettings 개체가 복사되고 생성된 각 작성기에 대해 읽기 전용으로 표시됩니다.The XmlWriterSettings object is copied and marked read-only for each created writer. XmlWriterSettings 인스턴스에서 설정을 변경해도 설정이 같은 기존 작성기에는 영향을 주지 않습니다.Changes to the settings on an XmlWriterSettings instance do not affect existing writers with the same settings. 그러므로 같은 설정을 사용하면 같은 기능을 갖춘 여러 작성기를 만들 수 있습니다.Thus, you can use the same settings to create multiple writers with the same functionality. 또는 XmlWriterSettings 인스턴스에서 설정을 수정하고 다른 기능 집합이 포함된 새 작성기를 만들 수 있습니다.Or, you can modify the settings on an XmlWriterSettings instance and create a new writer with a different set of features.

  • 기존 XML 작성기에 기능을 추가 합니다.Add features to an existing XML writer. Create 메서드는 다른 XmlWriter 개체를 허용할 수 있습니다.The Create method can accept another XmlWriter object. 내부 XmlWriter 개체를 정적으로 생성 하는 XML 작성기를 사용할 필요가 없습니다 Create 메서드.The underlying XmlWriter object does not have to be an XML writer created by the static Create method. 예를 들어, 추가 기능을 추가 하려면 사용자 정의 XML 작성기를 지정할 수 있습니다.For example, you can specify a user-defined XML writer to add additional features to.

  • 향상 된 규칙 검사에 대 한 규정 준수 등의 기능을 최대한 활용 합니다 XML 1.0 권장 사항 에서만 사용할 수 있는 XmlWriter 정적으로 생성 된 개체 Create 메서드.Take full advantage of features such as better conformance checking and compliance to the XML 1.0 recommendation that are available only on XmlWriter objects created by the static Create method.

사용 하는 경우는 Create 받지 않은 오버 로드는 XmlWriterSettings 개체를 다음 기본 작성기 설정이 사용 됩니다.If you use a Create overload that doesn't accept an XmlWriterSettings object, the following default writer settings are used:

설정Setting 기본값Default
CheckCharacters true
CloseOutput false
ConformanceLevel ConformanceLevel.Document
Encoding Encoding.UTF8
Indent false
IndentChars 공백 두 개Two spaces
NamespaceHandling Default (제거 없음)Default (no removal)
NewLineChars \r\n(캐리지 리턴, 줄 바꿈)\r\n (carriage return, new line)
NewLineHandling NewLineHandling.Replace
NewLineOnAttributes false
OmitXmlDeclaration false
OutputMethod XmlOutputMethod.Xml
WriteEndDocumentOnClose true

참고

.NET Framework에 포함 되어 있지만 합니다 XmlTextWriter 구체적인 구현인 클래스의를 XmlWriter 만드는 것을 권장 클래스 XmlWriter 를 사용 하 여 인스턴스를 Create 메서드.Although the .NET Framework includes the XmlTextWriter class, which is a concrete implementation of the XmlWriter class, we recommend that you create XmlWriter instances by using the Create method.

Create(XmlWriter, XmlWriterSettings) Create(XmlWriter, XmlWriterSettings) Create(XmlWriter, XmlWriterSettings) Create(XmlWriter, XmlWriterSettings)

지정된 XmlWriterXmlWriter 개체를 사용하여 새 XmlWriterSettings 인스턴스를 만듭니다.Creates a new XmlWriter instance using the specified XmlWriter and XmlWriterSettings objects.

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 XmlWriter XmlWriter

내부 작성기로 사용할 XmlWriter 개체입니다.The XmlWriter object that you want to use as the underlying writer.

settings
XmlWriterSettings XmlWriterSettings XmlWriterSettings XmlWriterSettings

XmlWriterSettings 인스턴스를 구성하는 데 사용되는 XmlWriter 개체입니다.The XmlWriterSettings object used to configure the new XmlWriter instance. 값이 null이면 기본 설정이 지정된 XmlWriterSettings이 사용됩니다.If this is null, a XmlWriterSettings with default settings is used.

XmlWriterTransform(String, XmlWriter) 메서드와 함께 사용되는 경우 OutputSettings 속성을 사용하여 올바른 설정을 포함하는 XmlWriterSettings 개체를 가져와야 합니다.If the XmlWriter is being used with the Transform(String, XmlWriter) method, you should use the OutputSettings property to obtain an XmlWriterSettings object with the correct settings. 이에 따라 만들어진 XmlWriter 개체가 올바른 출력 설정을 갖게 됩니다.This ensures that the created XmlWriter object has the correct output settings.

반환

지정된 XmlWriter 개체를 래핑하는 XmlWriter 개체입니다.An XmlWriter object that is wrapped around the specified XmlWriter object.

예외

writer 값이 null입니다.The writer value is null.

설명

이 메서드는 기본 추가 기능을 사용 하면 XmlWriter 개체입니다.This method allows you add additional features to an underlying XmlWriter object. 내부 XmlWriter 개체에 의해 생성 된 개체 수를 XmlWriter.Create 메서드 또는 사용 하 여 만든 개체는 XmlTextWriter 구현 합니다.The underlying XmlWriter object can be an object created by the XmlWriter.Create method, or an object created using the XmlTextWriter implementation.

Create(String, XmlWriterSettings) Create(String, XmlWriterSettings) Create(String, XmlWriterSettings) Create(String, XmlWriterSettings)

파일 이름과 XmlWriter 개체를 사용하여 새 XmlWriterSettings 인스턴스를 만듭니다.Creates a new XmlWriter instance using the filename and XmlWriterSettings object.

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);
static member Create : string * System.Xml.XmlWriterSettings -> System.Xml.XmlWriter
Public Shared Function Create (outputFileName As String, settings As XmlWriterSettings) As XmlWriter

매개 변수

outputFileName
String String String String

쓰기에 사용할 파일입니다.The file to which you want to write. XmlWriter는 지정된 경로에 파일을 만들어 XML 1.0 텍스트 구문으로 해당 파일에 씁니다.The XmlWriter creates a file at the specified path and writes to it in XML 1.0 text syntax. outputFileName은 파일 시스템 경로여야 합니다.The outputFileName must be a file system path.

settings
XmlWriterSettings XmlWriterSettings XmlWriterSettings XmlWriterSettings

XmlWriterSettings 인스턴스를 구성하는 데 사용되는 XmlWriter 개체입니다.The XmlWriterSettings object used to configure the new XmlWriter instance. 값이 null이면 기본 설정이 지정된 XmlWriterSettings이 사용됩니다.If this is null, a XmlWriterSettings with default settings is used.

XmlWriterTransform(String, XmlWriter) 메서드와 함께 사용되는 경우 OutputSettings 속성을 사용하여 올바른 설정을 포함하는 XmlWriterSettings 개체를 가져와야 합니다.If the XmlWriter is being used with the Transform(String, XmlWriter) method, you should use the OutputSettings property to obtain an XmlWriterSettings object with the correct settings. 이에 따라 만들어진 XmlWriter 개체가 올바른 출력 설정을 갖게 됩니다.This ensures that the created XmlWriter object has the correct output settings.

반환

예외

예제

다음 예제에서는 XmlWriter 정의 된 설정 사용 하 여 개체입니다.The following example creates an XmlWriter object with the defined settings.

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
Imports System.IO
Imports System.Xml
Imports System.Text
Imports Microsoft.VisualBasic

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) Create(TextWriter, XmlWriterSettings) Create(TextWriter, XmlWriterSettings) Create(TextWriter, XmlWriterSettings)

XmlWriterTextWriter 개체를 사용하여 새 XmlWriterSettings 인스턴스를 만듭니다.Creates a new XmlWriter instance using the TextWriter and XmlWriterSettings objects.

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 TextWriter TextWriter

쓰기에 사용할 TextWriter입니다.The TextWriter to which you want to write. XmlWriter는 XML 1.0 텍스트 구문을 작성한 후 지정된 TextWriter에 추가합니다.The XmlWriter writes XML 1.0 text syntax and appends it to the specified TextWriter.

settings
XmlWriterSettings XmlWriterSettings XmlWriterSettings XmlWriterSettings

XmlWriterSettings 인스턴스를 구성하는 데 사용되는 XmlWriter 개체입니다.The XmlWriterSettings object used to configure the new XmlWriter instance. 값이 null이면 기본 설정이 지정된 XmlWriterSettings이 사용됩니다.If this is null, a XmlWriterSettings with default settings is used.

XmlWriterTransform(String, XmlWriter) 메서드와 함께 사용되는 경우 OutputSettings 속성을 사용하여 올바른 설정을 포함하는 XmlWriterSettings 개체를 가져와야 합니다.If the XmlWriter is being used with the Transform(String, XmlWriter) method, you should use the OutputSettings property to obtain an XmlWriterSettings object with the correct settings. 이에 따라 만들어진 XmlWriter 개체가 올바른 출력 설정을 갖게 됩니다.This ensures that the created XmlWriter object has the correct output settings.

반환

예외

예제

다음 예제에서는 XML 문자열을 씁니다.The following example writes out an XML string.

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) Create(Stream, XmlWriterSettings) Create(Stream, XmlWriterSettings) Create(Stream, XmlWriterSettings)

스트림과 XmlWriter 개체를 사용하여 새 XmlWriterSettings 인스턴스를 만듭니다.Creates a new XmlWriter instance using the stream and XmlWriterSettings object.

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 Stream Stream Stream

작성하려는 스트림입니다.The stream to which you want to write. XmlWriter는 XML 1.0 텍스트 구문을 작성한 후 지정된 스트림에 추가합니다.The XmlWriter writes XML 1.0 text syntax and appends it to the specified stream.

settings
XmlWriterSettings XmlWriterSettings XmlWriterSettings XmlWriterSettings

XmlWriterSettings 인스턴스를 구성하는 데 사용되는 XmlWriter 개체입니다.The XmlWriterSettings object used to configure the new XmlWriter instance. 값이 null이면 기본 설정이 지정된 XmlWriterSettings이 사용됩니다.If this is null, a XmlWriterSettings with default settings is used.

XmlWriterTransform(String, XmlWriter) 메서드와 함께 사용되는 경우 OutputSettings 속성을 사용하여 올바른 설정을 포함하는 XmlWriterSettings 개체를 가져와야 합니다.If the XmlWriter is being used with the Transform(String, XmlWriter) method, you should use the OutputSettings property to obtain an XmlWriterSettings object with the correct settings. 이에 따라 만들어진 XmlWriter 개체가 올바른 출력 설정을 갖게 됩니다.This ensures that the created XmlWriter object has the correct output settings.

반환

예외

stream 값이 null입니다.The stream value is null.

예제

다음 예제에서는 XML 조각을 메모리 스트림으로 씁니다.The following example writes an XML fragment to a memory stream.

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 additonal 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 additonal processing on the stream.

설명

XmlWriter 항상 바이트 순서 표시 (BOM) 기본 데이터 스트림에 씁니다. 그러나 일부 스트림에 BOM 없어야 합니다.XmlWriter always writes a Byte Order Mark (BOM) to the underlying data stream; however, some streams must not have a BOM. BOM을 생략할를 새로 만듭니다 XmlWriterSettings 개체 및 인코딩 속성을 새 설정 UTF8Encoding false로 설정 하는 생성자에서 부울 값을 가진 개체입니다.To omit the BOM, create a new XmlWriterSettings object and set the Encoding property to be a new UTF8Encoding object with the Boolean value in the constructor set to false.

Create(StringBuilder, XmlWriterSettings) Create(StringBuilder, XmlWriterSettings) Create(StringBuilder, XmlWriterSettings) Create(StringBuilder, XmlWriterSettings)

XmlWriterStringBuilder 개체를 사용하여 새 XmlWriterSettings 인스턴스를 만듭니다.Creates a new XmlWriter instance using the StringBuilder and XmlWriterSettings objects.

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 StringBuilder StringBuilder

쓰기에 사용할 StringBuilder입니다.The StringBuilder to which to write to. XmlWriter가 쓰는 콘텐츠는 StringBuilder에 추가됩니다.Content written by the XmlWriter is appended to the StringBuilder.

settings
XmlWriterSettings XmlWriterSettings XmlWriterSettings XmlWriterSettings

XmlWriterSettings 인스턴스를 구성하는 데 사용되는 XmlWriter 개체입니다.The XmlWriterSettings object used to configure the new XmlWriter instance. 값이 null이면 기본 설정이 지정된 XmlWriterSettings이 사용됩니다.If this is null, a XmlWriterSettings with default settings is used.

XmlWriterTransform(String, XmlWriter) 메서드와 함께 사용되는 경우 OutputSettings 속성을 사용하여 올바른 설정을 포함하는 XmlWriterSettings 개체를 가져와야 합니다.If the XmlWriter is being used with the Transform(String, XmlWriter) method, you should use the OutputSettings property to obtain an XmlWriterSettings object with the correct settings. 이에 따라 만들어진 XmlWriter 개체가 올바른 출력 설정을 갖게 됩니다.This ensures that the created XmlWriter object has the correct output settings.

반환

예외

builder 값이 null입니다.The builder value is null.

Create(StringBuilder) Create(StringBuilder) Create(StringBuilder) Create(StringBuilder)

지정된 XmlWriter를 사용하여 새 StringBuilder 인스턴스를 만듭니다.Creates a new XmlWriter instance using the specified 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 StringBuilder StringBuilder

쓰기에 사용할 StringBuilder입니다.The StringBuilder to which to write to. XmlWriter가 쓰는 콘텐츠는 StringBuilder에 추가됩니다.Content written by the XmlWriter is appended to the StringBuilder.

반환

예외

builder 값이 null입니다.The builder value is null.

설명

이 오버 로드를 사용 하는 경우는 XmlWriterSettings 기본 설정 사용 하 여 개체를 XML 작성기를 만드는 데 사용 됩니다.When you use this overload, an XmlWriterSettings object with default settings is used to create the XML writer.

설정Setting 기본값Default
CheckCharacters true
CloseOutput false
ConformanceLevel ConformanceLevel.Document
Encoding Encoding.UTF8
Indent false
IndentChars 공백 두 개Two spaces
NamespaceHandling Default (제거 없음)Default (no removal)
NewLineChars \r\n(캐리지 리턴, 줄 바꿈)\r\n (carriage return, new line)
NewLineHandling NewLineHandling.Replace
NewLineOnAttributes false
OmitXmlDeclaration false
OutputMethod XmlOutputMethod.Xml
WriteEndDocumentOnClose true

사용 하는 오버 로드를 사용 하 여 만들어진된 XML 작성기에서 지원할 기능을 지정 하려는 경우는 XmlWriterSettings 해당 인수의 하나로 개체를 전달를 XmlWriterSettings 사용자 지정 설정 사용 하 여 개체.If you want to specify the features to support on the created XML writer, use an overload that takes an XmlWriterSettings object as one of its arguments, and pass in a XmlWriterSettings object with your custom settings.

Create(String) Create(String) Create(String) Create(String)

지정된 파일 이름을 사용하여 새 XmlWriter 인스턴스를 만듭니다.Creates a new XmlWriter instance using the specified filename.

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 String String String

쓰기에 사용할 파일입니다.The file to which you want to write. XmlWriter는 지정된 경로에 파일을 만들어 XML 1.0 텍스트 구문으로 해당 파일에 씁니다.The XmlWriter creates a file at the specified path and writes to it in XML 1.0 text syntax. outputFileName은 파일 시스템 경로여야 합니다.The outputFileName must be a file system path.

반환

예외

예제

다음 예제에서는 XmlWriter 개체 및 책 노드를 씁니다.The following example creates an XmlWriter object and writes a book node.

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 작성기를 만드는 데 사용 됩니다.When you use this overload, an XmlWriterSettings object with default settings is used to create the XML writer.

설정Setting 기본값Default
CheckCharacters true
CloseOutput false
ConformanceLevel ConformanceLevel.Document
Encoding Encoding.UTF8
Indent false
IndentChars 공백 두 개Two spaces
NamespaceHandling Default (제거 없음)Default (no removal)
NewLineChars \r\n(캐리지 리턴, 줄 바꿈)\r\n (carriage return, new line)
NewLineHandling NewLineHandling.Replace
NewLineOnAttributes false
OmitXmlDeclaration false
OutputMethod XmlOutputMethod.Xml
WriteEndDocumentOnClose true

사용 하는 오버 로드를 사용 하 여 만들어진된 XML 작성기에서 지원할 기능을 지정 하려는 경우는 XmlWriterSettings 해당 인수의 하나로 개체를 전달를 XmlWriterSettings 사용자 지정 설정 사용 하 여 개체.If you want to specify the features to support on the created XML writer, use an overload that takes an XmlWriterSettings object as one of its arguments, and pass in a XmlWriterSettings object with your custom settings.

Create(TextWriter) Create(TextWriter) Create(TextWriter) Create(TextWriter)

지정된 XmlWriter를 사용하여 새 TextWriter 인스턴스를 만듭니다.Creates a new XmlWriter instance using the specified 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 TextWriter TextWriter

쓰기에 사용할 TextWriter입니다.The TextWriter to which you want to write. XmlWriter는 XML 1.0 텍스트 구문을 작성한 후 지정된 TextWriter에 추가합니다.The XmlWriter writes XML 1.0 text syntax and appends it to the specified TextWriter.

반환

예외

예제

다음 예제에서는 콘솔에 출력 하는 작성기를 만듭니다.The following example creates a writer that outputs to the console.

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 작성기를 만드는 데 사용 됩니다.When you use this overload, an XmlWriterSettings object with default settings is used to create the XML writer.

설정Setting 기본값Default
CheckCharacters true
CloseOutput false
ConformanceLevel ConformanceLevel.Document
Encoding Encoding.UTF8
Indent false
IndentChars 공백 두 개Two spaces
NamespaceHandling Default (제거 없음)Default (no removal)
NewLineChars \r\n(캐리지 리턴, 줄 바꿈)\r\n (carriage return, new line)
NewLineHandling NewLineHandling.Replace
NewLineOnAttributes false
OmitXmlDeclaration false
OutputMethod XmlOutputMethod.Xml
WriteEndDocumentOnClose true

만들어진된 작성기에서 지원할 기능을 지정 하려는 경우 사용 하는 오버 로드는 XmlWriterSettings 해당 인수의 하나로 개체를 전달는 XmlWriterSettings 사용자 지정 설정 사용 하 여 개체.If you want to specify the features to support on the created writer, use an overload that takes an XmlWriterSettings object as one of its arguments, and pass in an XmlWriterSettings object with your custom settings.

Create(Stream) Create(Stream) Create(Stream) Create(Stream)

지정된 스트림을 사용하여 새 XmlWriter 인스턴스를 만듭니다.Creates a new XmlWriter instance using the specified stream.

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 Stream Stream Stream

작성하려는 스트림입니다.The stream to which you want to write. XmlWriter는 XML 1.0 텍스트 구문을 작성한 후 지정된 스트림에 추가합니다.The XmlWriter writes XML 1.0 text syntax and appends it to the specified stream.

반환

예외

stream 값이 null입니다.The stream value is null.

예제

다음 예제에서는 XML 조각을 메모리 스트림으로 씁니다.The following example writes an XML fragment to a memory stream. (사용 된 Create(Stream, XmlWriterSettings) 새 XML 기록기 인스턴스에서 설정을 구성 하는 오버 로드 합니다.)(It uses the Create(Stream, XmlWriterSettings) overload, which also configures the settings on the new XML writer instance.)

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 additonal 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 additonal processing on the stream.

설명

이 오버 로드를 사용 하는 경우는 XmlWriterSettings 다음 기본 설정 사용 하 여 개체를 XML 작성기를 만드는 데 사용 됩니다.When you use this overload, an XmlWriterSettings object with the following default settings is used to create the XML writer:

설정Setting 기본값Default
CheckCharacters true
CloseOutput false
ConformanceLevel ConformanceLevel.Document
Encoding Encoding.UTF8
Indent false
IndentChars 공백 두 개Two spaces
NamespaceHandling Default (제거 없음)Default (no removal)
NewLineChars \r\n(캐리지 리턴, 줄 바꿈)\r\n (carriage return, new line)
NewLineHandling NewLineHandling.Replace
NewLineOnAttributes false
OmitXmlDeclaration false
OutputMethod XmlOutputMethod.Xml
WriteEndDocumentOnClose true

만들어진된 작성기에서 지원할 기능을 지정 하려는 경우 사용 하는 오버 로드는 XmlWriterSettings 해당 인수의 하나로 개체를 전달는 XmlWriterSettings 사용자 지정 설정 사용 하 여 개체.If you want to specify the features to support on the created writer, use an overload that takes an XmlWriterSettings object as one of its arguments, and pass in an XmlWriterSettings object with your custom settings.

또한 XmlWriter 항상 바이트 순서 표시 (BOM) 기본 데이터 스트림에 씁니다. 그러나 일부 스트림에 BOM 없어야 합니다.Also, XmlWriter always writes a Byte Order Mark (BOM) to the underlying data stream; however, some streams must not have a BOM. BOM을 생략할를 새로 만듭니다 XmlWriterSettings 개체 및 인코딩 속성을 새 설정 UTF8Encoding false로 설정 하는 생성자에서 부울 값을 가진 개체입니다.To omit the BOM, create a new XmlWriterSettings object and set the Encoding property to be a new UTF8Encoding object with the Boolean value in the constructor set to false.

Create(XmlWriter) Create(XmlWriter) Create(XmlWriter) Create(XmlWriter)

지정된 XmlWriter 개체를 사용하여 새 XmlWriter 인스턴스를 만듭니다.Creates a new XmlWriter instance using the specified XmlWriter object.

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

내부 작성기로 사용할 XmlWriter 개체입니다.The XmlWriter object that you want to use as the underlying writer.

반환

지정된 XmlWriter 개체를 래핑하는 XmlWriter 개체입니다.An XmlWriter object that is wrapped around the specified XmlWriter object.

예외

writer 값이 null입니다.The writer value is null.

설명

이 메서드는 기본 기능을 사용 하면 XmlWriter 개체입니다.This method allows you add features to an underlying XmlWriter object. 내부 XmlWriter 개체에 의해 생성 된 개체 수를 XmlWriter.Create 메서드 또는 사용 하 여 만든 개체는 XmlTextWriter 구현 합니다.The underlying XmlWriter object can be an object created by the XmlWriter.Create method, or an object created using the XmlTextWriter implementation.

이 오버 로드를 사용 하는 경우는 XmlWriterSettings 기본 설정 사용 하 여 개체를 XML 작성기를 만드는 데 사용 됩니다.When you use this overload, an XmlWriterSettings object with default settings is used to create the XML writer.

설정Setting 기본값Default
CheckCharacters true
CloseOutput false
ConformanceLevel ConformanceLevel.Document
Encoding Encoding.UTF8
Indent false
IndentChars 공백 두 개Two spaces
NamespaceHandling Default (제거 없음)Default (no removal)
NewLineChars \r\n(캐리지 리턴, 줄 바꿈)\r\n (carriage return, new line)
NewLineHandling NewLineHandling.Replace
NewLineOnAttributes false
OmitXmlDeclaration false
OutputMethod XmlOutputMethod.Xml
WriteEndDocumentOnClose true

사용 하는 오버 로드를 사용 하 여 만들어진된 XML 작성기에서 지원할 기능을 지정 하려는 경우는 XmlWriterSettings 해당 인수의 하나로 개체를 전달를 XmlWriterSettings 사용자 지정 설정 사용 하 여 개체.If you want to specify the features to support on the created XML writer, use an overload that takes an XmlWriterSettings object as one of its arguments, and pass in a XmlWriterSettings object with your custom settings.

적용 대상