XDeclaration Class

Definition

代表 XML 宣告。Represents an XML declaration.

public ref class XDeclaration
public class XDeclaration
type XDeclaration = class
Public Class XDeclaration
Inheritance
XDeclaration

Remarks

XML 宣告是用來宣告 XML 版本、編碼,以及 XML 檔是否為獨立的。An XML declaration is used to declare the XML version, the encoding, and whether or not the XML document is standalone. 此類別代表 XML 宣告的 XML 概念。This class represents the XML concept of an XML declaration.

就像 XML 標準一樣,宣告也會與檔相關聯。Just as in the XML standard, declarations are associated with a document. 當您建立檔時,可以選擇指定檔的宣告。When you create a document, you have the option to specify the declaration for the document. XDocument 類別包含 Declaration 屬性,可讓您設定或取得宣告。The XDocument class contains the Declaration property, which allows you to set or get the declaration. 如需如何使用 XML 宣告序列化 XML 樹狀結構的詳細資訊,請參閱使用 xml宣告進行序列化。For information about how to serialize an XML tree with an XML declaration, see Serializing with an XML Declaration.

Constructors

XDeclaration(String, String, String)

使用指定的版本、編碼和獨立狀態,初始化 XDeclaration 類別的新執行個體。Initializes a new instance of the XDeclaration class with the specified version, encoding, and standalone status.

XDeclaration(XDeclaration)

從另一個 XDeclaration 物件初始化 XDeclaration 類別的新執行個體。Initializes a new instance of the XDeclaration class from another XDeclaration object.

Properties

Encoding

取得或設定這個文件的編碼方式。Gets or sets the encoding for this document.

Standalone

取得或設定這個文件的獨立屬性。Gets or sets the standalone property for this document.

Version

取得或設定這個文件的版本屬性。Gets or sets the version property for this document.

Methods

Equals(Object)

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

(Inherited from Object)
GetHashCode()

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

(Inherited from Object)
GetType()

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

(Inherited from Object)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

提供宣告做為格式化的字串。Provides the declaration as a formatted string.

Applies to

See also