XmlWriterSettings.OmitXmlDeclaration XmlWriterSettings.OmitXmlDeclaration XmlWriterSettings.OmitXmlDeclaration XmlWriterSettings.OmitXmlDeclaration Property

정의

XML 선언을 생략할지 여부를 나타내는 값을 가져오거나 설정합니다.Gets or sets a value indicating whether to omit an XML declaration.

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

속성 값

XML 선언을 생략하려면 true이고, 그렇지 않으면 false입니다.true to omit the XML declaration; otherwise, false. 기본값은 false로, XML 선언이 작성됩니다.The default is false, an XML declaration is written.

예제

다음 예제에서는 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 인스턴스 텍스트 콘텐츠를 출력 하는이 설정이 무시 되 고, 그렇지 않으면입니다.This property only applies to XmlWriter instances that output text content; otherwise, this setting is ignored.

하는 경우 OmitXmlDeclaration 로 설정 된 false, XML 선언이 자동으로 작성 됩니다If OmitXmlDeclaration is set to false, The XML declaration is written automatically

경우에 항상 XML 선언을 쓸지 ConformanceLevel 로 설정 된 Document경우에 OmitXmlDeclaration 로 설정 된 true합니다.The XML declaration is always written if ConformanceLevel is set to Document, even if OmitXmlDeclaration is set to true.

경우에 XML 선언을 작성 되지 않습니다 ConformanceLevel 로 설정 된 Fragment합니다.The XML declaration is never written if ConformanceLevel is set to Fragment. 호출할 수 있습니다 WriteProcessingInstruction 을 명시적으로 XML 선언을 작성 합니다.You can call WriteProcessingInstruction to explicitly write out an XML declaration.

적용 대상