XNamespace.Xml 属性

定义

获取与 XML URI (XNamespacehttp://www.w3.org/XML/1998/namespace) 对应的 对象。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; }
member this.Xml : System.Xml.Linq.XNamespace
Public Shared ReadOnly Property Xml As XNamespace

属性值

对应于 XML URI 的 XNamespacehttp://www.w3.org/XML/1998/namespace)。The XNamespace that corresponds to the XML URI (http://www.w3.org/XML/1998/namespace).

示例

下面的示例演示如何在 XML 树中创建 xml:space="preserve" 特性: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>  

注解

某些标准化属性(如 space)位于 http://www.w3.org/XML/1998/namespace 命名空间中。Certain standardized attributes, such as space, are in the http://www.w3.org/XML/1998/namespace namespace. W3C 标准版指定不需要将此命名空间声明为 XML 树中的属性。The W3C standard specifies that this namespace does not have to be declared as an attribute in the XML tree. 它是始终自动在 XML 分析器中使用的保留命名空间。It is a reserved namespace that is always automatically available in the XML parser.

适用于

另请参阅