XmlTextWriter XmlTextWriter XmlTextWriter XmlTextWriter Class

定義

表示提供產生資料流或檔案的快速、非快取、順向方法的寫入器,這些資料流或檔案中包含符合 W3C Extensible Markup Language (XML) 1.0 與 XML Recommendation 中命名空間的 XML 資料。Represents a writer that provides a fast, non-cached, forward-only way of generating streams or files containing XML data that conforms to the W3C Extensible Markup Language (XML) 1.0 and the Namespaces in XML recommendations.

從 .NET Framework 2.0 開始,建議您改用 XmlWriter 類別。Starting with the .NET Framework 2.0, we recommend that you use the XmlWriter class instead.

public ref class XmlTextWriter : System::Xml::XmlWriter
public class XmlTextWriter : System.Xml.XmlWriter
type XmlTextWriter = class
    inherit XmlWriter
Public Class XmlTextWriter
Inherits XmlWriter
繼承
XmlTextWriterXmlTextWriterXmlTextWriterXmlTextWriter

備註

這個類別會實作XmlWriter類別。This class implements the XmlWriter class.

注意

從.NET Framework 2.0 開始,我們建議您建立XmlWriter使用的執行個體XmlWriter.Create方法和XmlWriterSettings類別,以利用新的功能。Starting with the .NET Framework 2.0, we recommend that you create XmlWriter instances by using the XmlWriter.Create method and the XmlWriterSettings class to take advantage of new functionality.

XmlTextWriter 會維護命名空間堆疊,對應至目前的項目堆疊中定義的所有命名空間。XmlTextWriter maintains a namespace stack corresponding to all the namespaces defined in the current element stack. 使用XmlTextWriter您可以手動宣告命名空間。Using XmlTextWriter you can declare namespaces manually.

w.WriteStartElement("root");  
w.WriteAttributeString("xmlns", "x", null, "urn:1");  
 w.WriteStartElement("item","urn:1");  
 w.WriteEndElement();  
 w.WriteStartElement("item","urn:1");  
 w.WriteEndElement();  
w.WriteEndElement();  

上述的 C# 程式碼會產生下列輸出。The above C# code produces the following output. XmlTextWriter 升級以避免它重複兩個子項目上的根項目的命名空間宣告。XmlTextWriter promotes the namespace declaration to the root element to avoid having it duplicated on the two child elements. 子項目中挑選前置詞的命名空間宣告。The child elements pick up the prefix from the namespace declaration.

<root xmlns:x="urn:1">  
 <x:item/>  
 <x:item/>  
</x:root>  

XmlTextWriter 也可讓您覆寫目前的命名空間宣告。XmlTextWriter also allows you to override the current namespace declaration. 在下列範例中,命名空間 URI"123"會覆寫產生的 XML 項目,"abc" <x:node xmlns:x="abc"/>In the following example, the namespace URI "123" is overridden by "abc" to produce the XML element <x:node xmlns:x="abc"/>.

w.WriteStartElement("x","node","123");  
w.WriteAttributeString("xmlns","x",null,"abc");  

使用的寫入方法會採用前置詞做為引數,您也可以指定使用哪個前置詞。By using the write methods that take a prefix as an argument you can also specify which prefix to use. 在下列範例中,兩個不同的前置詞會對應至相同的命名空間 URI 產生的 XML 文字<x:root xmlns:x="urn:1"><y:item xmlns:y="urn:1"/></x:root>In the following example, two different prefixes are mapped to the same namespace URI to produce the XML text <x:root xmlns:x="urn:1"><y:item xmlns:y="urn:1"/></x:root>.

XmlTextWriter w = new XmlTextWriter(Console.Out);  
w.WriteStartElement("x","root","urn:1");  
 w.WriteStartElement("y","item","urn:1");  
 w.WriteEndElement();  
w.WriteEndElement();  
w.Close();  

如果有多個不同的前置詞對應至相同的命名空間 URI 的命名空間宣告XmlTextWriter將逐步引導命名空間宣告的堆疊回溯,並挑選一個最接近。If there are multiple namespace declarations mapping different prefixes to the same namespace URI, XmlTextWriter walks the stack of namespace declarations backwards and picks the closest one.

XmlTextWriter w = new XmlTextWriter(Console.Out);  
w.Formatting = Formatting.Indented;  
w.WriteStartElement("x","root","urn:1");  
w.WriteStartElement("y","item","urn:1");  
w.WriteAttributeString("attr","urn:1","123");  
w.WriteEndElement();  
w.WriteEndElement();  
w.Close();  

在上述 C# 範例中,因為WriteAttributeString呼叫未指定前置詞,寫入器會使用推入命名空間堆疊,最後一個前置詞,並產生下列 XML:In the above C# example, because the WriteAttributeString call does not specify a prefix, the writer uses the last prefix pushed onto the namespace stack, and produces the following XML:

<x:root xmlns:x="urn:1">  
 <y:item y:attr="123" xmlns:y="urn:1" />  
</x:root>  

如果發生命名空間衝突,XmlTextWriter解析這些藉由產生替代的前置詞。If namespace conflicts occur, XmlTextWriter resolves them by generating alternate prefixes. 比方說,如果屬性和項目具有相同首碼但不同的命名空間,XmlWriter產生替代的前置詞的屬性。For example, if an attribute and element have the same prefix but different namespaces, XmlWriter generates an alternate prefix for the attribute. 名為產生的首碼n{i}其中i是數字 1 開始。The generated prefixes are named n{i} where i is a number beginning at 1. 數字會重設為 1,每個項目。The number is reset to 1 for each element.

命名空間 URI 相關聯的屬性必須具有的前置詞 (命名空間並不適用於屬性的預設值)。Attributes which are associated with a namespace URI must have a prefix (default namespaces do not apply to attributes). 這符合 W3C Namespaces in XML 建議事項的區段 5.2。This conforms to section 5.2 of the W3C Namespaces in XML recommendation. 如果屬性參考命名空間 URI,但不是指定前置詞,則寫入器會產生屬性的前置詞。If an attribute references a namespace URI, but does not specify a prefix, the writer generates a prefix for the attribute.

在撰寫空項目時,額外的空間之間加入標記名稱和結尾標記,例如<item />When writing an empty element, an additional space is added between tag name and the closing tag, for example <item />. 這會提供用於舊版瀏覽器的相容性。This provides compatibility with older browsers.

String做為方法參數nullString.Empty相等。When a String is used as method parameter, null and String.Empty are equivalent. String.Empty 遵循 W3C 規則。String.Empty follows the W3C rules.

若要撰寫強型別的資料,使用XmlConvert類別,以將資料類型轉換為字串。To write strongly typed data, use the XmlConvert class to convert data types to string. 例如,下列 C# 程式碼會將轉換的資料DoubleString,並將寫入之項目的<price>19.95</price>For example, the following C# code converts the data from Double to String and writes the element <price>19.95</price>.

Double price = 19.95;  
writer.WriteElementString("price", XmlConvert.ToString(price));  

XmlTextWriter 不會檢查下列:XmlTextWriter does not check for the following:

  • 屬性和項目名稱中有無效的字元。Invalid characters in attribute and element names.

  • 不符合指定的編碼方式的 Unicode 字元。Unicode characters that do not fit the specified encoding. 如果 Unicode 字元不符合指定的編碼,XmlTextWriter不會不會逸出的 Unicode 字元到字元實體。If the Unicode characters do not fit the specified encoding, the XmlTextWriter does not escape the Unicode characters into character entities.

  • 重複的屬性。Duplicate attributes.

  • DOCTYPE 公用識別項或系統識別項中的字元。Characters in the DOCTYPE public identifier or system identifier.

安全性考量Security Considerations

下列項目會使用時的考慮事項XmlTextWriter類別。The following items are things to consider when working with the XmlTextWriter class.

  • 擲回例外狀況XmlTextWriter可能會洩露您不想要的路徑資訊反昇取決於應用程式。Exceptions thrown by the XmlTextWriter can disclose path information that you do not want bubbled up to the application. 應用程式必須捕捉例外狀況並予以適當處理。Your applications must catch exceptions and process them appropriately.

  • XmlTextWriter 傳遞到其他應用程式時,基礎資料流會對該應用程式公開。When you pass the XmlTextWriter to another application the underlying stream is exposed to that application. 如果您需要將 XmlTextWriter 傳遞到非完全信任的應用程式,則應改用 XmlWriter 方法所建立的 Create 物件。If you need to pass the XmlTextWriter to a semi-trusted application, you should use an XmlWriter object created by the Create method instead.

  • XmlTextWriter不會驗證傳遞至任何資料WriteDocTypeWriteRaw方法。The XmlTextWriter does not validate any data that is passed to the WriteDocType or WriteRaw methods. 您不應將任意資料傳遞給這些方法。You should not pass arbitrary data to these methods.

  • 如果變更預設設定,則產生的輸出是語式正確的 XML 資料不保證。If the default settings are changed, there is no guarantee that the generated output is well-formed XML data.

  • 不接受條款支援元件,例如Encoding物件,從受信任的來源。Do not accept supporting components, such as an Encoding object, from an untrusted source.

建構函式

XmlTextWriter(Stream, Encoding) XmlTextWriter(Stream, Encoding) XmlTextWriter(Stream, Encoding) XmlTextWriter(Stream, Encoding)

使用指定的資料流和編碼方式,建立 XmlTextWriter 類別的執行個體。Creates an instance of the XmlTextWriter class using the specified stream and encoding.

XmlTextWriter(String, Encoding) XmlTextWriter(String, Encoding) XmlTextWriter(String, Encoding) XmlTextWriter(String, Encoding)

使用指定的檔案建立 XmlTextWriter 類別的執行個體。Creates an instance of the XmlTextWriter class using the specified file.

XmlTextWriter(TextWriter) XmlTextWriter(TextWriter) XmlTextWriter(TextWriter) XmlTextWriter(TextWriter)

使用指定的 TextWriter 來建立 XmlTextWriter 類別的執行個體。Creates an instance of the XmlTextWriter class using the specified TextWriter.

屬性

BaseStream BaseStream BaseStream BaseStream

取得基礎資料流物件。Gets the underlying stream object.

Formatting Formatting Formatting Formatting

表示格式化輸出的方式。Indicates how the output is formatted.

Indentation Indentation Indentation Indentation

取得或設定當 Formatting 設定為 Formatting.Indented 時,每一層級要寫入多少縮排字元。Gets or sets how many IndentChars to write for each level in the hierarchy when Formatting is set to Formatting.Indented.

IndentChar IndentChar IndentChar IndentChar

取得或設定當 Formatting 設為 Formatting.Indented 時用於縮排的字元。Gets or sets which character to use for indenting when Formatting is set to Formatting.Indented.

Namespaces Namespaces Namespaces Namespaces

取得或設定值,指出是否支援命名空間。Gets or sets a value indicating whether to do namespace support.

QuoteChar QuoteChar QuoteChar QuoteChar

取得或設定用來括住屬性值的字元。Gets or sets which character to use to quote attribute values.

Settings Settings Settings Settings

取得 XmlWriterSettings 物件,用於建立這個 XmlWriter 執行個體。Gets the XmlWriterSettings object used to create this XmlWriter instance.

(Inherited from XmlWriter)
WriteState WriteState WriteState WriteState

取得寫入器的狀態。Gets the state of the writer.

XmlLang XmlLang XmlLang XmlLang

取得目前的 xml:lang 範圍。Gets the current xml:lang scope.

XmlSpace XmlSpace XmlSpace XmlSpace

取得 XmlSpace,表示目前的 xml:space 範圍。Gets an XmlSpace representing the current xml:space scope.

方法

Close() Close() Close() Close()

關閉這個資料流與基礎資料流。Closes this stream and the underlying stream.

Dispose() Dispose() Dispose() Dispose()

釋放 XmlWriter 類別目前的執行個體所使用的全部資源。Releases all resources used by the current instance of the XmlWriter class.

(Inherited from XmlWriter)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

釋放 XmlWriter 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。Releases the unmanaged resources used by the XmlWriter and optionally releases the managed resources.

(Inherited from XmlWriter)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
Flush() Flush() Flush() Flush()

將緩衝區的所有內容清空至基礎資料流,然後清空基礎資料流。Flushes whatever is in the buffer to the underlying streams and also flushes the underlying stream.

FlushAsync() FlushAsync() FlushAsync() FlushAsync()

以非同步的方式將緩衝區的所有內容清空至基礎資料流,然後清空基礎資料流。Asynchronously flushes whatever is in the buffer to the underlying streams and also flushes the underlying stream.

(Inherited from XmlWriter)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
LookupPrefix(String) LookupPrefix(String) LookupPrefix(String) LookupPrefix(String)

傳回最接近命名空間 URI 在目前命名空間範圍中定義的前置詞。Returns the closest prefix defined in the current namespace scope for the namespace URI.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)
WriteAttributes(XmlReader, Boolean) WriteAttributes(XmlReader, Boolean) WriteAttributes(XmlReader, Boolean) WriteAttributes(XmlReader, Boolean)

在衍生類別中覆寫時,寫出在 XmlReader 的目前位置找到的所有屬性。When overridden in a derived class, writes out all the attributes found at the current position in the XmlReader.

(Inherited from XmlWriter)
WriteAttributesAsync(XmlReader, Boolean) WriteAttributesAsync(XmlReader, Boolean) WriteAttributesAsync(XmlReader, Boolean) WriteAttributesAsync(XmlReader, Boolean)

非同步寫出在 XmlReader 中的目前位置找到的所有屬性。Asynchronously writes out all the attributes found at the current position in the XmlReader.

(Inherited from XmlWriter)
WriteAttributeString(String, String) WriteAttributeString(String, String) WriteAttributeString(String, String) WriteAttributeString(String, String)

在衍生類別中覆寫時,寫出具有指定的區域名稱與數值的屬性。When overridden in a derived class, writes out the attribute with the specified local name and value.

(Inherited from XmlWriter)
WriteAttributeString(String, String, String) WriteAttributeString(String, String, String) WriteAttributeString(String, String, String) WriteAttributeString(String, String, String)

在衍生類別中覆寫時,寫入具有指定區域名稱、命名空間 URI 和值的屬性。When overridden in a derived class, writes an attribute with the specified local name, namespace URI, and value.

(Inherited from XmlWriter)
WriteAttributeString(String, String, String, String) WriteAttributeString(String, String, String, String) WriteAttributeString(String, String, String, String) WriteAttributeString(String, String, String, String)

在衍生類別中覆寫時,寫出具有指定的前置詞、區域名稱、命名空間 URI 及其值的屬性。When overridden in a derived class, writes out the attribute with the specified prefix, local name, namespace URI, and value.

(Inherited from XmlWriter)
WriteAttributeStringAsync(String, String, String, String) WriteAttributeStringAsync(String, String, String, String) WriteAttributeStringAsync(String, String, String, String) WriteAttributeStringAsync(String, String, String, String)

以非同步的方式寫出具有指定之前置詞、區域名稱、命名空間 URI 和值的屬性。Asynchronously writes out the attribute with the specified prefix, local name, namespace URI, and value.

(Inherited from XmlWriter)
WriteBase64(Byte[], Int32, Int32) WriteBase64(Byte[], Int32, Int32) WriteBase64(Byte[], Int32, Int32) WriteBase64(Byte[], Int32, Int32)

以 base64 編碼指定的二進位位元組並寫出產生的文字。Encodes the specified binary bytes as base64 and writes out the resulting text.

WriteBase64Async(Byte[], Int32, Int32) WriteBase64Async(Byte[], Int32, Int32) WriteBase64Async(Byte[], Int32, Int32) WriteBase64Async(Byte[], Int32, Int32)

以非同步的方式將指定的二進位位元組編碼為 base64 並寫出產生的文字。Asynchronously encodes the specified binary bytes as Base64 and writes out the resulting text.

(Inherited from XmlWriter)
WriteBinHex(Byte[], Int32, Int32) WriteBinHex(Byte[], Int32, Int32) WriteBinHex(Byte[], Int32, Int32) WriteBinHex(Byte[], Int32, Int32)

以 Binhex 編碼指定的二進位位元組,並寫出產生的文字。Encodes the specified binary bytes as binhex and writes out the resulting text.

WriteBinHexAsync(Byte[], Int32, Int32) WriteBinHexAsync(Byte[], Int32, Int32) WriteBinHexAsync(Byte[], Int32, Int32) WriteBinHexAsync(Byte[], Int32, Int32)

以非同步的方式將指定的二進位位元組編碼為 BinHex 並寫出產生的文字。Asynchronously encodes the specified binary bytes as BinHex and writes out the resulting text.

(Inherited from XmlWriter)
WriteCData(String) WriteCData(String) WriteCData(String) WriteCData(String)

寫出包含指定文字的 <![CDATA[...]]> 區塊。Writes out a <![CDATA[...]]> block containing the specified text.

WriteCDataAsync(String) WriteCDataAsync(String) WriteCDataAsync(String) WriteCDataAsync(String)

以非同步的方式寫出包含指定文字的 <![CDATA[...]]> 區塊。Asynchronously writes out a <![CDATA[...]]> block containing the specified text.

(Inherited from XmlWriter)
WriteCharEntity(Char) WriteCharEntity(Char) WriteCharEntity(Char) WriteCharEntity(Char)

強制產生指定的 Unicode 字元值的字元實體。Forces the generation of a character entity for the specified Unicode character value.

WriteCharEntityAsync(Char) WriteCharEntityAsync(Char) WriteCharEntityAsync(Char) WriteCharEntityAsync(Char)

以非同步的方式強制產生指定的 Unicode 字元值的字元實體。Asynchronously forces the generation of a character entity for the specified Unicode character value.

(Inherited from XmlWriter)
WriteChars(Char[], Int32, Int32) WriteChars(Char[], Int32, Int32) WriteChars(Char[], Int32, Int32) WriteChars(Char[], Int32, Int32)

一次將文字寫入一個緩衝區。Writes text one buffer at a time.

WriteCharsAsync(Char[], Int32, Int32) WriteCharsAsync(Char[], Int32, Int32) WriteCharsAsync(Char[], Int32, Int32) WriteCharsAsync(Char[], Int32, Int32)

以非同步的方式一次將文字寫入一個緩衝區。Asynchronously writes text one buffer at a time.

(Inherited from XmlWriter)
WriteComment(String) WriteComment(String) WriteComment(String) WriteComment(String)

寫出包含指定文字的註解 <!--...-->。Writes out a comment <!--...--> containing the specified text.

WriteCommentAsync(String) WriteCommentAsync(String) WriteCommentAsync(String) WriteCommentAsync(String)

以非同步的方式寫出包含指定文字的註解 <!--...-->。Asynchronously writes out a comment <!--...--> containing the specified text.

(Inherited from XmlWriter)
WriteDocType(String, String, String, String) WriteDocType(String, String, String, String) WriteDocType(String, String, String, String) WriteDocType(String, String, String, String)

寫入具有指定名稱與選擇性屬性的 DOCTYPE 宣告。Writes the DOCTYPE declaration with the specified name and optional attributes.

WriteDocTypeAsync(String, String, String, String) WriteDocTypeAsync(String, String, String, String) WriteDocTypeAsync(String, String, String, String) WriteDocTypeAsync(String, String, String, String)

以非同步的方式寫入具有指定名稱與選擇性屬性的 DOCTYPE 宣告。Asynchronously writes the DOCTYPE declaration with the specified name and optional attributes.

(Inherited from XmlWriter)
WriteElementString(String, String) WriteElementString(String, String) WriteElementString(String, String) WriteElementString(String, String)

寫入具有指定之區域名稱和值的項目。Writes an element with the specified local name and value.

(Inherited from XmlWriter)
WriteElementString(String, String, String) WriteElementString(String, String, String) WriteElementString(String, String, String) WriteElementString(String, String, String)

寫入具有指定之區域名稱、命名空間 URI 和值的項目。Writes an element with the specified local name, namespace URI, and value.

(Inherited from XmlWriter)
WriteElementString(String, String, String, String) WriteElementString(String, String, String, String) WriteElementString(String, String, String, String) WriteElementString(String, String, String, String)

寫入具有指定的前置詞、區域名稱、命名空間 URI 和值的項目。Writes an element with the specified prefix, local name, namespace URI, and value.

(Inherited from XmlWriter)
WriteElementStringAsync(String, String, String, String) WriteElementStringAsync(String, String, String, String) WriteElementStringAsync(String, String, String, String) WriteElementStringAsync(String, String, String, String)

以非同步的方式寫入具有指定之前置詞、區域名稱、命名空間 URI 和值的項目。Asynchronously writes an element with the specified prefix, local name, namespace URI, and value.

(Inherited from XmlWriter)
WriteEndAttribute() WriteEndAttribute() WriteEndAttribute() WriteEndAttribute()

關閉先前的 WriteStartAttribute(String, String, String) 呼叫。Closes the previous WriteStartAttribute(String, String, String) call.

WriteEndAttributeAsync() WriteEndAttributeAsync() WriteEndAttributeAsync() WriteEndAttributeAsync()

非同步關閉上一個 WriteStartAttribute(String, String) 呼叫。Asynchronously closes the previous WriteStartAttribute(String, String) call.

(Inherited from XmlWriter)
WriteEndDocument() WriteEndDocument() WriteEndDocument() WriteEndDocument()

關閉任何開啟的項目或屬性,並將寫入器回復開始狀態。Closes any open elements or attributes and puts the writer back in the Start state.

WriteEndDocumentAsync() WriteEndDocumentAsync() WriteEndDocumentAsync() WriteEndDocumentAsync()

以非同步的方式關閉任何開啟的項目或屬性,並將寫入器回復開始狀態。Asynchronously closes any open elements or attributes and puts the writer back in the Start state.

(Inherited from XmlWriter)
WriteEndElement() WriteEndElement() WriteEndElement() WriteEndElement()

關閉一個項目並快顯對應的命名空間範圍。Closes one element and pops the corresponding namespace scope.

WriteEndElementAsync() WriteEndElementAsync() WriteEndElementAsync() WriteEndElementAsync()

以非同步的方式關閉一個項目並取出對應的命名空間範圍。Asynchronously closes one element and pops the corresponding namespace scope.

(Inherited from XmlWriter)
WriteEntityRef(String) WriteEntityRef(String) WriteEntityRef(String) WriteEntityRef(String)

寫出如 &name; 的實體參考。Writes out an entity reference as &name;.

WriteEntityRefAsync(String) WriteEntityRefAsync(String) WriteEntityRefAsync(String) WriteEntityRefAsync(String)

以非同步的方式將實體參考寫出為 &name;Asynchronously writes out an entity reference as &name;.

(Inherited from XmlWriter)
WriteFullEndElement() WriteFullEndElement() WriteFullEndElement() WriteFullEndElement()

關閉一個項目並快顯對應的命名空間範圍。Closes one element and pops the corresponding namespace scope.

WriteFullEndElementAsync() WriteFullEndElementAsync() WriteFullEndElementAsync() WriteFullEndElementAsync()

以非同步的方式關閉一個項目並取出對應的命名空間範圍。Asynchronously closes one element and pops the corresponding namespace scope.

(Inherited from XmlWriter)
WriteName(String) WriteName(String) WriteName(String) WriteName(String)

寫出指定的名稱,以確保它是符合 W3C XML 1.0 建議的有效名稱。Writes out the specified name, ensuring it is a valid name according to the W3C XML 1.0 recommendation.

WriteNameAsync(String) WriteNameAsync(String) WriteNameAsync(String) WriteNameAsync(String)

非同步地寫出指定的名稱,以確保它是符合 W3C XML 1.0 建議 (https://www.w3.org/TR/1998/REC-xml-19980210#NT-Name) (英文) 的有效名稱。Asynchronously writes out the specified name, ensuring it is a valid name according to the W3C XML 1.0 recommendation (https://www.w3.org/TR/1998/REC-xml-19980210#NT-Name).

(Inherited from XmlWriter)
WriteNmToken(String) WriteNmToken(String) WriteNmToken(String) WriteNmToken(String)

寫出指定的名稱,以確保它是符合 W3C XML 1.0 建議的有效 NmTokenWrites out the specified name, ensuring it is a valid NmToken according to the W3C XML 1.0 recommendation.

WriteNmTokenAsync(String) WriteNmTokenAsync(String) WriteNmTokenAsync(String) WriteNmTokenAsync(String)

非同步地寫出指定的名稱,以確保它是符合 W3C XML 1.0 建議 (https://www.w3.org/TR/1998/REC-xml-19980210#NT-Name) (英文) 的有效 NmToken。Asynchronously writes out the specified name, ensuring it is a valid NmToken according to the W3C XML 1.0 recommendation (https://www.w3.org/TR/1998/REC-xml-19980210#NT-Name).

(Inherited from XmlWriter)
WriteNode(XmlReader, Boolean) WriteNode(XmlReader, Boolean) WriteNode(XmlReader, Boolean) WriteNode(XmlReader, Boolean)

在衍生類別中覆寫時,從讀取器複製所有內容至寫入器,並將讀取器移至下一個同層級 (Sibling) 的開頭。When overridden in a derived class, copies everything from the reader to the writer and moves the reader to the start of the next sibling.

(Inherited from XmlWriter)
WriteNode(XPathNavigator, Boolean) WriteNode(XPathNavigator, Boolean) WriteNode(XPathNavigator, Boolean) WriteNode(XPathNavigator, Boolean)

XPathNavigator 物件中的所有項目複製到寫入器。Copies everything from the XPathNavigator object to the writer. XPathNavigator 的位置保持不變。The position of the XPathNavigator remains unchanged.

(Inherited from XmlWriter)
WriteNodeAsync(XmlReader, Boolean) WriteNodeAsync(XmlReader, Boolean) WriteNodeAsync(XmlReader, Boolean) WriteNodeAsync(XmlReader, Boolean)

以非同步的方式從讀取器複製所有內容至寫入器,並將讀取器移至下一個同層級 (Sibling) 的開頭。Asynchronously copies everything from the reader to the writer and moves the reader to the start of the next sibling.

(Inherited from XmlWriter)
WriteNodeAsync(XPathNavigator, Boolean) WriteNodeAsync(XPathNavigator, Boolean) WriteNodeAsync(XPathNavigator, Boolean) WriteNodeAsync(XPathNavigator, Boolean)

以非同步方式將所有項目從 XPathNavigator 物件複製到寫入器。Asynchronously copies everything from the XPathNavigator object to the writer. XPathNavigator 的位置保持不變。The position of the XPathNavigator remains unchanged.

(Inherited from XmlWriter)
WriteProcessingInstruction(String, String) WriteProcessingInstruction(String, String) WriteProcessingInstruction(String, String) WriteProcessingInstruction(String, String)

寫出名稱與文字之間有空白的處理指示,如下所示:<?name text?>。Writes out a processing instruction with a space between the name and text as follows: <?name text?>.

WriteProcessingInstructionAsync(String, String) WriteProcessingInstructionAsync(String, String) WriteProcessingInstructionAsync(String, String) WriteProcessingInstructionAsync(String, String)

以非同步方式寫出名稱與文字之間有空白的處理指示,如下所示:<?name text?>。Asynchronously writes out a processing instruction with a space between the name and text as follows: <?name text?>.

(Inherited from XmlWriter)
WriteQualifiedName(String, String) WriteQualifiedName(String, String) WriteQualifiedName(String, String) WriteQualifiedName(String, String)

寫出命名空間限定名稱。Writes out the namespace-qualified name. 這個方法會查詢在指定之命名空間範圍中的前置詞。This method looks up the prefix that is in scope for the given namespace.

WriteQualifiedNameAsync(String, String) WriteQualifiedNameAsync(String, String) WriteQualifiedNameAsync(String, String) WriteQualifiedNameAsync(String, String)

以非同步的方式寫出命名空間限定名稱。Asynchronously writes out the namespace-qualified name. 這個方法會查詢在指定之命名空間範圍中的前置詞。This method looks up the prefix that is in scope for the given namespace.

(Inherited from XmlWriter)
WriteRaw(Char[], Int32, Int32) WriteRaw(Char[], Int32, Int32) WriteRaw(Char[], Int32, Int32) WriteRaw(Char[], Int32, Int32)

從字元緩衝區手動寫入未經處理的標記。Writes raw markup manually from a character buffer.

WriteRaw(String) WriteRaw(String) WriteRaw(String) WriteRaw(String)

從字串手動寫入未經處理的標記 (Raw Markup)。Writes raw markup manually from a string.

WriteRawAsync(Char[], Int32, Int32) WriteRawAsync(Char[], Int32, Int32) WriteRawAsync(Char[], Int32, Int32) WriteRawAsync(Char[], Int32, Int32)

以非同步的方式從字元緩衝區手動寫入未經處理的標記。Asynchronously writes raw markup manually from a character buffer.

(Inherited from XmlWriter)
WriteRawAsync(String) WriteRawAsync(String) WriteRawAsync(String) WriteRawAsync(String)

以非同步的方式從字串手動寫入未經處理的標記 (Raw Markup)。Asynchronously writes raw markup manually from a string.

(Inherited from XmlWriter)
WriteStartAttribute(String) WriteStartAttribute(String) WriteStartAttribute(String) WriteStartAttribute(String)

寫入具有指定之區域名稱的屬性開頭。Writes the start of an attribute with the specified local name.

(Inherited from XmlWriter)
WriteStartAttribute(String, String) WriteStartAttribute(String, String) WriteStartAttribute(String, String) WriteStartAttribute(String, String)

寫入具有指定之區域名稱和命名空間 URI 之屬性的開頭。Writes the start of an attribute with the specified local name and namespace URI.

(Inherited from XmlWriter)
WriteStartAttribute(String, String, String) WriteStartAttribute(String, String, String) WriteStartAttribute(String, String, String) WriteStartAttribute(String, String, String)

寫入屬性的開頭。Writes the start of an attribute.

WriteStartAttributeAsync(String, String, String) WriteStartAttributeAsync(String, String, String) WriteStartAttributeAsync(String, String, String) WriteStartAttributeAsync(String, String, String)

以非同步的方式寫入具有指定之前置詞、本機名稱和命名空間 URI 之屬性的開頭。Asynchronously writes the start of an attribute with the specified prefix, local name, and namespace URI.

(Inherited from XmlWriter)
WriteStartDocument() WriteStartDocument() WriteStartDocument() WriteStartDocument()

使用版本「1.0」寫入 XML 宣告。Writes the XML declaration with the version "1.0".

WriteStartDocument(Boolean) WriteStartDocument(Boolean) WriteStartDocument(Boolean) WriteStartDocument(Boolean)

使用版本「1.0」寫入 XML 宣告與獨立屬性。Writes the XML declaration with the version "1.0" and the standalone attribute.

WriteStartDocumentAsync() WriteStartDocumentAsync() WriteStartDocumentAsync() WriteStartDocumentAsync()

以非同步的方式使用「1.0」版寫入 XML 宣告。Asynchronously writes the XML declaration with the version "1.0".

(Inherited from XmlWriter)
WriteStartDocumentAsync(Boolean) WriteStartDocumentAsync(Boolean) WriteStartDocumentAsync(Boolean) WriteStartDocumentAsync(Boolean)

以非同步的方式使用「1.0」版寫入 XML 宣告與獨立屬性。Asynchronously writes the XML declaration with the version "1.0" and the standalone attribute.

(Inherited from XmlWriter)
WriteStartElement(String) WriteStartElement(String) WriteStartElement(String) WriteStartElement(String)

在衍生類別中覆寫時,寫出具有指定之區域名稱的開頭標記。When overridden in a derived class, writes out a start tag with the specified local name.

(Inherited from XmlWriter)
WriteStartElement(String, String) WriteStartElement(String, String) WriteStartElement(String, String) WriteStartElement(String, String)

在衍生類別中覆寫時,寫入指定的開頭標記並與指定的命名空間產生關聯。When overridden in a derived class, writes the specified start tag and associates it with the given namespace.

(Inherited from XmlWriter)
WriteStartElement(String, String, String) WriteStartElement(String, String, String) WriteStartElement(String, String, String) WriteStartElement(String, String, String)

寫入指定的開頭標記,並使它與指定的命名空間及前置詞產生關聯。Writes the specified start tag and associates it with the given namespace and prefix.

WriteStartElementAsync(String, String, String) WriteStartElementAsync(String, String, String) WriteStartElementAsync(String, String, String) WriteStartElementAsync(String, String, String)

以非同步的方式寫入指定的開頭標記,並將它與指定的命名空間與前置詞產生關聯。Asynchronously writes the specified start tag and associates it with the given namespace and prefix.

(Inherited from XmlWriter)
WriteString(String) WriteString(String) WriteString(String) WriteString(String)

寫入指定的文字內容。Writes the given text content.

WriteStringAsync(String) WriteStringAsync(String) WriteStringAsync(String) WriteStringAsync(String)

以非同步的方式寫入指定的文字內容。Asynchronously writes the given text content.

(Inherited from XmlWriter)
WriteSurrogateCharEntity(Char, Char) WriteSurrogateCharEntity(Char, Char) WriteSurrogateCharEntity(Char, Char) WriteSurrogateCharEntity(Char, Char)

產生和寫入 Surrogate 字元字組的 Surrogate 字元實體。Generates and writes the surrogate character entity for the surrogate character pair.

WriteSurrogateCharEntityAsync(Char, Char) WriteSurrogateCharEntityAsync(Char, Char) WriteSurrogateCharEntityAsync(Char, Char) WriteSurrogateCharEntityAsync(Char, Char)

以非同步的方式產生和寫入 Surrogate 字元字組的 Surrogate 字元實體。Asynchronously generates and writes the surrogate character entity for the surrogate character pair.

(Inherited from XmlWriter)
WriteValue(Boolean) WriteValue(Boolean) WriteValue(Boolean) WriteValue(Boolean)

寫入 Boolean 值。Writes a Boolean value.

(Inherited from XmlWriter)
WriteValue(DateTime) WriteValue(DateTime) WriteValue(DateTime) WriteValue(DateTime)

寫入 DateTime 值。Writes a DateTime value.

(Inherited from XmlWriter)
WriteValue(DateTimeOffset) WriteValue(DateTimeOffset) WriteValue(DateTimeOffset) WriteValue(DateTimeOffset)

寫入 DateTimeOffset 值。Writes a DateTimeOffset value.

(Inherited from XmlWriter)
WriteValue(Decimal) WriteValue(Decimal) WriteValue(Decimal) WriteValue(Decimal)

寫入 Decimal 值。Writes a Decimal value.

(Inherited from XmlWriter)
WriteValue(Double) WriteValue(Double) WriteValue(Double) WriteValue(Double)

寫入 Double 值。Writes a Double value.

(Inherited from XmlWriter)
WriteValue(Int32) WriteValue(Int32) WriteValue(Int32) WriteValue(Int32)

寫入 Int32 值。Writes a Int32 value.

(Inherited from XmlWriter)
WriteValue(Int64) WriteValue(Int64) WriteValue(Int64) WriteValue(Int64)

寫入 Int64 值。Writes a Int64 value.

(Inherited from XmlWriter)
WriteValue(Object) WriteValue(Object) WriteValue(Object) WriteValue(Object)

寫入物件值。Writes the object value.

(Inherited from XmlWriter)
WriteValue(Single) WriteValue(Single) WriteValue(Single) WriteValue(Single)

寫入單精確度浮點數。Writes a single-precision floating-point number.

(Inherited from XmlWriter)
WriteValue(String) WriteValue(String) WriteValue(String) WriteValue(String)

寫入 String 值。Writes a String value.

(Inherited from XmlWriter)
WriteWhitespace(String) WriteWhitespace(String) WriteWhitespace(String) WriteWhitespace(String)

寫出指定的空白字元。Writes out the given white space.

WriteWhitespaceAsync(String) WriteWhitespaceAsync(String) WriteWhitespaceAsync(String) WriteWhitespaceAsync(String)

以非同步的方式寫出指定的空白字元。Asynchronously writes out the given white space.

(Inherited from XmlWriter)

明確介面實作

IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose()

如需這個成員的說明,請參閱 Dispose()For a description of this member, see Dispose().

(Inherited from XmlWriter)

適用於

另請參閱