XmlTextWriter.WriteCharEntity(Char) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 유니코드 문자 값에 대한 문자 엔터티를 강제로 생성합니다.
public:
override void WriteCharEntity(char ch);
public override void WriteCharEntity(char ch);
override this.WriteCharEntity : char -> unit
Public Overrides Sub WriteCharEntity (ch As Char)
매개 변수
- ch
- Char
문자 엔터티를 생성할 유니코드 문자입니다.
예외
문자가 서로게이트 쌍 문자 범위에 0xd800 - 0xdfff있거나 텍스트로 인해 잘 구성되지 않은 XML 문서가 생성됩니다.
WriteState은 Closed입니다.
예제
다음 예제에서는 이 메서드를 WriteCharEntity 사용하여 전자 메일 주소를 작성합니다.
using System;
using System.Xml;
public class Sample {
public static void Main() {
XmlTextWriter writer = null;
try {
writer = new XmlTextWriter (Console.Out);
// Write an element.
writer.WriteStartElement("address");
// Write an email address using entities
// for the @ and . characters.
writer.WriteString("someone");
writer.WriteCharEntity('@');
writer.WriteString("example");
writer.WriteCharEntity('.');
writer.WriteString("com");
writer.WriteEndElement();
}
finally {
// Close the writer.
if (writer != null)
writer.Close();
}
}
}
Imports System.Xml
Public Class Sample
Public Shared Sub Main()
Dim writer As XmlTextWriter = Nothing
Try
writer = new XmlTextWriter(Console.Out)
' Write an element.
writer.WriteStartElement("address")
' Write an email address using entities
' for the @ and . characters.
writer.WriteString("someone")
writer.WriteCharEntity("@"c)
writer.WriteString("example")
writer.WriteCharEntity("."c)
writer.WriteString("com")
writer.WriteEndElement()
Finally
' Close the writer.
If writer IsNot Nothing
writer.Close()
End If
End Try
End Sub
End Class
설명
메모
새로운 기능을 활용하기 위해 XmlWriter 인스턴스를 XmlWriter.Create 메서드를 사용하고 XmlWriterSettings 클래스를 활용하여 만드는 것을 권장합니다.
이 메서드는 유니코드 문자를 16진수 문자 엔터티 참조 형식으로 씁니다.