XmlNamespaceManager.PopScope Method ()


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Pops a namespace scope off the stack.

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

Public Overridable Function PopScope As Boolean

Return Value

Type: System.Boolean

true if there are namespace scopes left on the stack; false if there are no more namespaces to pop.

When you call this method, all namespaces which were added to XmlNamespaceManager (by calling AddNamespace) since the last call to PopScope are removed.

The following example adds prefix/namespace pairs to the XmlNamespaceManager and then displays all the pairs in the collection.

Option Explicit
Option Strict

Imports System
Imports System.IO
Imports System.Xml

Public Class Sample

    Public Shared Sub Main()
        Dim test As New Sample()
    End Sub 'Main

    Public Sub New()
        ' Create the XmlNamespaceManager.
        Dim nt As New NameTable()
        Dim nsmgr As New XmlNamespaceManager(nt)

        ' Add prefix/namespace pairs to the XmlNamespaceManager.
        nsmgr.AddNamespace("", "www.wideworldimporters.com") 'Adds a default namespace.
        nsmgr.AddNamespace("europe", "www.wideworldimporters.com/europe")
        nsmgr.PushScope() 'Pushes a namespace scope on the stack.
        nsmgr.AddNamespace("", "www.lucernepublishing.com") 'Adds another default namespace.
        nsmgr.AddNamespace("partners", "www.lucernepublishing.com/partners")

        Console.WriteLine("Show all the prefix/namespace pairs in the XmlNamespaceManager...")
    End Sub 'NewNew

    Private Sub ShowAllNamespaces(nsmgr As XmlNamespaceManager)
            Dim prefix As String
            For Each prefix In  nsmgr
                Console.WriteLine("Prefix={0}, Namespace={1}", prefix, nsmgr.LookupNamespace(prefix))
            Next prefix
        Loop While nsmgr.PopScope()
    End Sub 'ShowAllNamespaces
End Class 'Sample

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top