語言

XNamespace.Xml 屬性

定義

取得 XNamespace 對應 XML URI (http://www.w3.org/XML/1998/namespace) 的物件。

public:
 static property System::Xml::Linq::XNamespace ^ Xml { System::Xml::Linq::XNamespace ^ get(); };
public static System.Xml.Linq.XNamespace Xml { get; }
static member Xml : System.Xml.Linq.XNamespace
Public Shared ReadOnly Property Xml As XNamespace

屬性值

該 XNamespace IT 對應 XML URI (http://www.w3.org/XML/1998/namespace)。

範例

以下範例展示了如何在 XML 樹中建立 xml:space="preserve" 屬性:

XElement root = new XElement("Root",
    new XAttribute(XNamespace.Xml + "space", "preserve"),
    new XElement("Child", "content")
);
Console.WriteLine(root);
Dim root As XElement = _
    <Root xml:space="preserve">
        <Child>content</Child>
    </Root>
Console.WriteLine(root)

此範例會產生下列輸出:

<Root xml:space="preserve">
  <Child>content</Child>
</Root>

備註

某些標準化屬性,例如 space,存在 http://www.w3.org/XML/1998/namespace 於命名空間中。 W3C 標準規定此命名空間不必在 XML 樹中宣告為屬性。 它是一個保留的命名空間,總是自動在 XML 解析器中可用。

適用於

另請參閱