XmlTextWriter.WriteString(String) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 텍스트 콘텐츠를 씁니다.
public:
override void WriteString(System::String ^ text);
public override void WriteString(string? text);
public override void WriteString(string text);
override this.WriteString : string -> unit
Public Overrides Sub WriteString (text As String)
매개 변수
- text
- String
쓸 텍스트입니다.
예외
텍스트 문자열에 잘못된 서로게이트 쌍이 포함되어 있습니다.
예제
다음 예제에서는 XML 조각을 씁니다.
using System;
using System.IO;
using System.Xml;
public class Sample
{
public static void Main()
{
//Create a writer to write XML to the console.
XmlTextWriter writer = null;
writer = new XmlTextWriter (Console.Out);
//Use indentation for readability.
writer.Formatting = Formatting.Indented;
writer.Indentation = 4;
//Write an element (this one is the root).
writer.WriteStartElement("book");
//Write the title element.
writer.WriteStartElement("title");
writer.WriteString("Pride And Prejudice");
writer.WriteEndElement();
//Write the close tag for the root element.
writer.WriteEndElement();
//Write the XML to file and close the writer.
writer.Close();
}
}
Option Explicit
Option Strict
Imports System.IO
Imports System.Xml
Public Class Sample
Public Shared Sub Main()
'Create a writer to write XML to the console.
Dim writer As XmlTextWriter = Nothing
writer = New XmlTextWriter(Console.Out)
'Use indentation for readability.
writer.Formatting = Formatting.Indented
writer.Indentation = 4
'Write an element (this one is the root).
writer.WriteStartElement("book")
'Write the title element.
writer.WriteStartElement("title")
writer.WriteString("Pride And Prejudice")
writer.WriteEndElement()
'Write the close tag for the root element.
writer.WriteEndElement()
'Write the XML to file and close the writer.
writer.Close()
End Sub
End Class
설명
메모
새로운 기능을 활용하기 위해 XmlWriter 인스턴스를 XmlWriter.Create 메서드를 사용하고 XmlWriterSettings 클래스를 활용하여 만드는 것을 권장합니다.
WriteString 은 다음을 수행합니다.
문자
&,<및>, 및&각각으로<>대체됩니다.0x-0x1F 범위의 문자 값(0x9, 0xA 및 0xD 공백 문자 제외)은 숫자 문자 엔터티(
�~�x1F)로 바뀝니다.특성 값의 컨텍스트에서 호출되는 경우
WriteString큰따옴표와 작은따옴표가 각각과 함께"'바뀝니다.
예를 들어 이 입력 문자열 test<item>test 은 .로 test<item>test작성됩니다.
또는 text 이 메서드는 nullString.Empty 데이터 콘텐츠가 없는 텍스트 노드를 씁니다.