XmlNode.Prefix XmlNode.Prefix XmlNode.Prefix XmlNode.Prefix Property

定義

取得或設定這個節點的命名空間前置詞。Gets or sets the namespace prefix of this node.

public:
 virtual property System::String ^ Prefix { System::String ^ get(); void set(System::String ^ value); };
public virtual string Prefix { get; set; }
member this.Prefix : string with get, set
Public Overridable Property Prefix As String

屬性值

這個節點的命名空間前置詞。The namespace prefix of this node. 例如, Prefix是 bk: book>元素<的 bk。For example, Prefix is bk for the element <bk:book>. 如果沒有前置詞,則這個屬性會傳回 String.Empty。If there is no prefix, this property returns String.Empty.

例外狀況

這個節點是唯讀的。This node is read-only.

指定的前置詞包含無效的字元。The specified prefix contains an invalid character.

指定的前置詞格式不正確。The specified prefix is malformed.

指定的前置詞為 "xml",且此節點的 namespaceURI 與 "http://www.w3.org/XML/1998/namespace" (英文) 的不同。The specified prefix is "xml" and the namespaceURI of this node is different from "http://www.w3.org/XML/1998/namespace".

此節點是一個屬性,且指定的前置詞是 "xmlns",而且此節點的 namespaceURI 與 http://www.w3.org/2000/xmlns/ (英文) 的不同。This node is an attribute and the specified prefix is "xmlns" and the namespaceURI of this node is different from "http://www.w3.org/2000/xmlns/ ".

這個節點是屬性,這個節點的 qualifiedName 是「xmlns」。This node is an attribute and the qualifiedName of this node is "xmlns".

備註

設定這個屬性時,如果允許的話, Name會在專案和屬性節點上變更保存限定名稱的屬性。Setting this property, when permitted, changes the Name property, which holds the qualified name, on Element and Attribute nodes. 在不能有前置詞的節點類型(例如 Text、Comment、EntityReference、CDATA、ProcessingInstruction、Document 和 DocumentFragment)上設定此屬性不會有任何作用。Setting this property on node types that cannot have a prefix (such as Text, Comment, EntityReference, CDATA, ProcessingInstruction, Document, and DocumentFragment) has no effect. 變更已知具有預設值之屬性的前置詞,並不會建立具有預設值的新屬性,而且會出現原始的前置詞,因為命名空間 URI 和本機名稱不會變更。Changing the prefix of an attribute that is known to have a default value, does not make a new attribute with the default value and the original prefix appear, since the namespace URI and local name do not change.

給繼承者的注意事項

在衍生Prefix類別中覆寫時,無法設定這個屬性。When overriding Prefix in a derived class, this property cannot be set.

適用於