XDocumentType 類別

定義

代表 XML 文件類型定義 (DTD)。Represents an XML Document Type Definition (DTD).

public ref class XDocumentType : System::Xml::Linq::XNode
public class XDocumentType : System.Xml.Linq.XNode
type XDocumentType = class
    inherit XNode
Public Class XDocumentType
Inherits XNode
繼承
XDocumentType

備註

XML 中的資料類型定義(DTD)是執行下列動作的一種方式:Data Type Definitions (DTD) in XML are a way to do the following:

  • 驗證 XML 樹狀結構的範圍有限。Validate XML trees to a limited extent.

  • 展開 [實體],這是一種文字取代形式。Expand entities, which is a form of text replacement.

  • 提供預設屬性。Supply default attributes.

此類別代表 DTD 的 XML 概念。This class represents the XML concept of a DTD.

LINQ to XMLLINQ to XML 中的 DTD 支援有限。DTD support in LINQ to XMLLINQ to XML is limited.

LINQ to XMLLINQ to XML 預設會擴充內部實體,但除非使用相關聯 XmlResolverXmlReader 來載入 XML 樹狀結構,否則它不會解析外部實體參考。will expand internal entities by default, but it will not resolve external entity references unless an XmlReader with an associated XmlResolver is used to load the XML tree.

LINQ to XMLLINQ to XML 不會對 DTD 驗證檔,但是您可以視需要使用驗證 XmlReader 來執行 DTD 驗證。will not validate a document against a DTD, but you can use a validating XmlReader to perform DTD validation if necessary.

若要針對 XML 架構驗證 LINQ to XMLLINQ to XML 樹狀結構,請使用 Validate 方法。To validate an LINQ to XMLLINQ to XML tree against an XML schema, use the Validate method.

當檔包含定義于 DTD 中的實體參考時,這些參考會在建立 XML 樹狀結構時展開。When a document contains entity references that are defined in a DTD, the references are expanded upon creation of the XML tree. 不過,當您序列化或儲存 XML 樹狀結構時,會保留展開之實體的內容;實體參考不是。However, when you serialize or save the XML tree, the content of the expanded entities is preserved; the entity references are not.

DTD 的預設屬性會具體化為 XML 樹狀結構中的一般屬性。Default attributes from the DTD will be materialized as regular attributes in the XML tree. 當 DTD 的預設屬性具體化之後,就無法判斷該屬性是否為 DTD 的預設屬性。After a default attribute from the DTD is materialized, there is no way to determine that the attribute was a default attribute from the DTD.

您可以使用包含內部 DTD 的 XML 檔來填入 XML 樹狀結構。You can populate an XML tree with an XML document that contains an internal DTD. 接著,XML 樹狀結構會包含 DocumentType 節點。The XML tree will then contain a DocumentType node. 當您序列化或儲存樹狀結構時,內部 DTD 也會儲存為檔的一部分。When you serialize or save the tree, the internal DTD will also be saved as part of the document.

建構函式

XDocumentType(String, String, String, String)

初始化 XDocumentType 類別的執行個體。Initializes an instance of the XDocumentType class.

XDocumentType(XDocumentType)

從其他 XDocumentType 物件初始化 XDocumentType 類別的執行個體。Initializes an instance of the XDocumentType class from another XDocumentType object.

屬性

BaseUri

取得此 XObject 的基底 URI。Gets the base URI for this XObject.

(繼承來源 XObject)
Document

取得這個 XDocumentXObjectGets the XDocument for this XObject.

(繼承來源 XObject)
InternalSubset

取得或設定這個文件類型定義 (DTD) 的內部子集。Gets or sets the internal subset for this Document Type Definition (DTD).

Name

取得或設定這個文件類型定義 (DTD) 的名稱。Gets or sets the name for this Document Type Definition (DTD).

NextNode

取得這個節點的下一個同層級 (Sibling) 節點。Gets the next sibling node of this node.

(繼承來源 XNode)
NodeType

取得此節點的節點類型。Gets the node type for this node.

Parent

取得這個 XElementXObjectGets the parent XElement of this XObject.

(繼承來源 XObject)
PreviousNode

取得這個節點的上一個同層級節點。Gets the previous sibling node of this node.

(繼承來源 XNode)
PublicId

取得或設定這個文件類型定義 (DTD) 的公用識別項。Gets or sets the public identifier for this Document Type Definition (DTD).

SystemId

取得或設定這個文件類型定義 (DTD) 的系統識別項。Gets or sets the system identifier for this Document Type Definition (DTD).

方法

AddAfterSelf(Object)

將指定的內容加入緊接在此節點後面的位置。Adds the specified content immediately after this node.

(繼承來源 XNode)
AddAfterSelf(Object[])

將指定的內容加入緊接在此節點後面的位置。Adds the specified content immediately after this node.

(繼承來源 XNode)
AddAnnotation(Object)

將物件加入此 XObject 的註釋清單。Adds an object to the annotation list of this XObject.

(繼承來源 XObject)
AddBeforeSelf(Object)

將指定的內容加入緊接在此節點前面的位置。Adds the specified content immediately before this node.

(繼承來源 XNode)
AddBeforeSelf(Object[])

將指定的內容加入緊接在此節點前面的位置。Adds the specified content immediately before this node.

(繼承來源 XNode)
Ancestors()

傳回這個節點之上階元素的集合。Returns a collection of the ancestor elements of this node.

(繼承來源 XNode)
Ancestors(XName)

傳回這個節點的上階元素之篩選的集合。Returns a filtered collection of the ancestor elements of this node. 集合中只會包含具有相符之 XName 的項目。Only elements that have a matching XName are included in the collection.

(繼承來源 XNode)
Annotation(Type)

從此 XObject 取得指定類型的第一個註釋物件。Gets the first annotation object of the specified type from this XObject.

(繼承來源 XObject)
Annotation<T>()

從此 XObject 取得指定類型的第一個註釋物件。Gets the first annotation object of the specified type from this XObject.

(繼承來源 XObject)
Annotations(Type)

取得此 XObject 之指定類型註釋的集合。Gets a collection of annotations of the specified type for this XObject.

(繼承來源 XObject)
Annotations<T>()

取得此 XObject 之指定類型註釋的集合。Gets a collection of annotations of the specified type for this XObject.

(繼承來源 XObject)
CreateReader()

建立這個節點的 XmlReaderCreates an XmlReader for this node.

(繼承來源 XNode)
CreateReader(ReaderOptions)

使用 readerOptions 參數指定的選項建立 XmlReaderCreates an XmlReader with the options specified by the readerOptions parameter.

(繼承來源 XNode)
ElementsAfterSelf()

依照文件順序,傳回這個節點之後同層級項目的集合。Returns a collection of the sibling elements after this node, in document order.

(繼承來源 XNode)
ElementsAfterSelf(XName)

依照文件順序,傳回這個節點之後同層級項目之篩選的集合。Returns a filtered collection of the sibling elements after this node, in document order. 集合中只會包含具有相符之 XName 的項目。Only elements that have a matching XName are included in the collection.

(繼承來源 XNode)
ElementsBeforeSelf()

依照文件順序,傳回這個節點之前同層級項目的集合。Returns a collection of the sibling elements before this node, in document order.

(繼承來源 XNode)
ElementsBeforeSelf(XName)

依照文件順序,傳回這個節點之前同層級項目之篩選的集合。Returns a filtered collection of the sibling elements before this node, in document order. 集合中只會包含具有相符之 XName 的項目。Only elements that have a matching XName are included in the collection.

(繼承來源 XNode)
Equals(Object)

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

(繼承來源 Object)
GetHashCode()

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

(繼承來源 Object)
GetType()

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

(繼承來源 Object)
IsAfter(XNode)

根據文件順序,判斷目前的節點是否出現在指定的節點之後。Determines if the current node appears after a specified node in terms of document order.

(繼承來源 XNode)
IsBefore(XNode)

根據文件順序,判斷目前的節點是否出現在指定的節點之前。Determines if the current node appears before a specified node in terms of document order.

(繼承來源 XNode)
MemberwiseClone()

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

(繼承來源 Object)
NodesAfterSelf()

依照文件順序,傳回這個節點之後同層級節點的集合。Returns a collection of the sibling nodes after this node, in document order.

(繼承來源 XNode)
NodesBeforeSelf()

依照文件順序,傳回這個節點之前同層級節點的集合。Returns a collection of the sibling nodes before this node, in document order.

(繼承來源 XNode)
Remove()

將這個節點從其父代 (Parent) 移除。Removes this node from its parent.

(繼承來源 XNode)
RemoveAnnotations(Type)

從這個 XObject 中移除指定之類型的註釋。Removes the annotations of the specified type from this XObject.

(繼承來源 XObject)
RemoveAnnotations<T>()

從這個 XObject 中移除指定之類型的註釋。Removes the annotations of the specified type from this XObject.

(繼承來源 XObject)
ReplaceWith(Object)

以指定的內容取代這個節點。Replaces this node with the specified content.

(繼承來源 XNode)
ReplaceWith(Object[])

以指定的內容取代這個節點。Replaces this node with the specified content.

(繼承來源 XNode)
ToString()

針對這個節點傳回縮排的 XML。Returns the indented XML for this node.

(繼承來源 XNode)
ToString(SaveOptions)

傳回這個節點的 XML (可選擇是否停用格式設定)。Returns the XML for this node, optionally disabling formatting.

(繼承來源 XNode)
WriteTo(XmlWriter)

將這個 XDocumentType 寫入 XmlWriterWrite this XDocumentType to an XmlWriter.

WriteToAsync(XmlWriter, CancellationToken)

將這個 XDocumentType 寫入指定的 XmlWriterWrites this XDocumentType to the specified XmlWriter.

事件

Changed

當此 XObject 或其任何子代發生變更時會引發。Raised when this XObject or any of its descendants have changed.

(繼承來源 XObject)
Changing

當此 XObject 或其任何子代發生變更時會引發。Raised when this XObject or any of its descendants are about to change.

(繼承來源 XObject)

明確介面實作

IXmlLineInfo.HasLineInfo()

取得值,指出此 XObject 是否具有行資訊。Gets a value indicating whether or not this XObject has line information.

(繼承來源 XObject)
IXmlLineInfo.LineNumber

取得基礎 XmlReader 所回報此 XObject 的行號。Gets the line number that the underlying XmlReader reported for this XObject.

(繼承來源 XObject)
IXmlLineInfo.LinePosition

取得基礎 XmlReader 所報告之此 XObject 的行位置。Gets the line position that the underlying XmlReader reported for this XObject.

(繼承來源 XObject)

擴充方法

CreateNavigator(XNode)

建立 XPathNavigatorXNodeCreates an XPathNavigator for an XNode.

CreateNavigator(XNode, XmlNameTable)

建立 XPathNavigatorXNodeCreates an XPathNavigator for an XNode. XmlNameTable 可讓 XPath 運算式處理時更有效率。The XmlNameTable enables more efficient XPath expression processing.

XPathEvaluate(XNode, String)

評估 XPath 運算式。Evaluates an XPath expression.

XPathEvaluate(XNode, String, IXmlNamespaceResolver)

評估 XPath 運算式,並使用指定的 IXmlNamespaceResolver 解析命名空間後置字元。Evaluates an XPath expression, resolving namespace prefixes using the specified IXmlNamespaceResolver.

XPathSelectElement(XNode, String)

使用 XPath 運算式選取 XElementSelects an XElement using a XPath expression.

XPathSelectElement(XNode, String, IXmlNamespaceResolver)

使用 XPath 運算式選取 XElement,並使用指定的 IXmlNamespaceResolver 解析命名空間後置字元。Selects an XElement using a XPath expression, resolving namespace prefixes using the specified IXmlNamespaceResolver.

XPathSelectElements(XNode, String)

使用 XPath 運算式選取項目的集合。Selects a collection of elements using an XPath expression.

XPathSelectElements(XNode, String, IXmlNamespaceResolver)

使用 XPath 運算式選取項目集合,並使用指定的 IXmlNamespaceResolver 解析命名空間後置字元。Selects a collection of elements using an XPath expression, resolving namespace prefixes using the specified IXmlNamespaceResolver.

ToXPathNavigable(XNode)

傳回存取子,讓您巡覽及編輯指定的 XNodeReturns an accessor that allows you to navigate and edit the specified XNode.

適用於

另請參閱