None Property
Collapse the table of content
Expand the table of content

XNamespace.None Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets the XNamespace object that corresponds to no namespace.

Namespace:  System.Xml.Linq
Assembly:  System.Xml.Linq (in System.Xml.Linq.dll)

'Declaration
Public Shared ReadOnly Property None As XNamespace

Property Value

Type: System.Xml.Linq.XNamespace
The XNamespace that corresponds to no namespace.

If an element or attribute is in no namespace, its namespace will be set to the namespace returned by this property.

The following example shows uses this property to determine which elements are in no namespace.


'add the following line to the the Imports section:
'Imports <xmlns:aw="http://www.adventure-works.com">
Dim output As New StringBuilder
Dim root As XElement = _
    <Root>
        <aw:ChildInNamespace>content</aw:ChildInNamespace>
        <ChildInNoNamespace>content</ChildInNoNamespace>
    </Root>

If (root.Name.Namespace Is XNamespace.None) Then
    output.Append("Root element is in no namespace")
    output.Append(Environment.NewLine)
Else
    output.Append("Root element is in a namespace")
    output.Append(Environment.NewLine)
End If

If (root.Element(GetXmlNamespace(aw) + "ChildInNamespace") _
        .Name.Namespace Is XNamespace.None) Then
    output.Append("ChildInNamespace element is in no namespace")
    output.Append(Environment.NewLine)
Else
    output.Append("ChildInNamespace element is in a namespace")
    output.Append(Environment.NewLine)
End If

OutputTextBlock.Text = output.ToString()


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft