XNamespace.Xml 屬性

定義

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

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 至 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 剖析器中自動取得。

適用於

另請參閱