XmlElementAttribute.Namespace 屬性

定義

取得或設定指派給類別序列化時所產生之 XML 項目的命名空間。Gets or sets the namespace assigned to the XML element that results when the class is serialized.

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

屬性值

XML 項目的命名空間。The namespace of the XML element.

備註

Namespace 屬性符合全球資訊網協會規格,也就是XML 中的命名空間The Namespace property conforms to the World Wide Web Consortium specification, Namespaces in XML.

若要建立與前置詞相關聯的命名空間,您必須建立一個 XmlSerializerNamespaces,其中包含 XML 檔中所使用的命名空間和首碼。To create namespaces that are associated with a prefix, you must create an XmlSerializerNamespaces that contains the namespaces and prefixes used in the XML document. 當您設定每個 XmlArrayAttribute的命名空間時,它必須符合 XmlSerializerNamespaces中的其中一個命名空間。As you set the namespace for each XmlArrayAttribute, it must match one of the namespaces in the XmlSerializerNamespaces. 產生 XML 時,每個陣列的前面會加上與指定的命名空間相關聯的前置詞。When the XML is generated, each array is correctly prefixed with the prefix associated with the specified namespace.

適用於