XNamespace.Xml Egenskap

Definition

Hämtar objektet XNamespace som motsvarar XML-URI:n (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

Egenskapsvärde

Det XNamespace som motsvarar XML-URI :n (http://www.w3.org/XML/1998/namespace).

Exempel

I följande exempel visas hur du skapar ett xml:space="preserve" attribut i ett XML-träd:

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)

Det här exemplet genererar följande utdata:

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

Kommentarer

Vissa standardiserade attribut, till exempel space, finns i http://www.w3.org/XML/1998/namespace namnområdet. W3C-standarden anger att det här namnområdet inte behöver deklareras som ett attribut i XML-trädet. Det är ett reserverat namnområde som alltid är automatiskt tillgängligt i XML-parsern.

Gäller för

Se även