Bewerken

Share via


XNamespace.Xml Property

Definition

Gets the XNamespace object that corresponds to the 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

Property Value

The XNamespace that corresponds to the XML URI (http://www.w3.org/XML/1998/namespace).

Examples

The following example shows how to create an xml:space="preserve" attribute in an XML tree:

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)

This example produces the following output:

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

Remarks

Certain standardized attributes, such as space, are in the http://www.w3.org/XML/1998/namespace namespace. The W3C standard specifies that this namespace does not have to be declared as an attribute in the XML tree. It is a reserved namespace that is always automatically available in the XML parser.

Applies to

See also