XmlElementAttribute.Namespace 屬性


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

 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 ,它必須符合中的其中一個命名空間 XmlSerializerNamespacesAs 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.