共用方式為


XmlRootAttribute.Namespace 屬性

定義

取得或設定 XML 根元素的命名空間。

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

屬性值

XML 元素的命名空間。

範例

以下範例將 應用 XmlRootAttribute 於類別並設定屬性 Namespace

[XmlRoot(Namespace = "http://www.cpandl.com")]
public class Group
{
   // Insert the members of the Group class.
}
<XmlRoot(Namespace := "http://www.cpandl.com")> _
Public Class Group
    ' Insert the members of the Group class.
End Class

備註

Namespace 屬性符合萬維網聯盟(WWC)在 XML 中命名空間(Namespaces)的規範。

要在 XML 文件中建立前綴命名空間,請建立 XmlSerializerNamespaces 一個包含所有前綴-命名空間對的物件。 你為每個 XmlArrayAttribute 物件設定的命名空間必須包含在物件中 XmlSerializerNamespaces 。 當 產生 XmlSerializer 文件時,會正確地為每個陣列項目加上元素名稱。

適用於

另請參閱