XmlWriterSettings.OmitXmlDeclaration 속성

정의

XML 선언을 생략할지 여부를 나타내는 값을 가져오거나 설정합니다.

public:
 property bool OmitXmlDeclaration { bool get(); void set(bool value); };
public bool OmitXmlDeclaration { get; set; }
member this.OmitXmlDeclaration : bool with get, set
Public Property OmitXmlDeclaration As Boolean

속성 값

Boolean

XML 선언을 생략하려면 true이고, 그렇지 않으면 false입니다. 기본값은 false로, XML 선언이 작성됩니다.

예제

다음 예제에서는 메모리 스트림에 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 만 적용되며, 그렇지 않으면 이 설정이 무시됩니다.

설정false되면 OmitXmlDeclaration XML 선언이 자동으로 작성됩니다.

XML 선언은 설정된 경우 ConformanceLevel 항상 기록됩니다 OmitXmlDeclaration Documenttrue.

로 설정된 Fragment경우 ConformanceLevel XML 선언은 기록되지 않습니다. XML 선언을 명시적으로 작성하도록 호출 WriteProcessingInstruction 할 수 있습니다.

적용 대상