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 ref class Group{};
[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 符合 XML 中名為 Namespaces 的World Wide Web Consortium 規格。

若要在 XML 檔中建立前置命名空間,請建立 XmlSerializerNamespaces 物件,其中包含所有前置詞命名空間組。 您為每個 XmlArrayAttribute 設定的命名空間必須包含在 物件中 XmlSerializerNamespacesXmlSerializer當 產生檔時,它會正確地為每個陣列專案加上元素名稱的前置詞。

適用於

另請參閱