Freigeben über


XmlNamespaceManager.PopScope Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Pops a namespace scope off the stack.

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

Syntax

'Declaration
Public Overridable Function PopScope As Boolean
public virtual bool PopScope()

Return Value

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

Remarks

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

Examples

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

Dim output As New StringBuilder()

' 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")

output.AppendLine("Show all the prefix/namespace pairs in the XmlNamespaceManager...")

Do
    Dim prefix As String
    For Each prefix In nsmgr
        output.AppendLine(("Prefix=" + prefix + " Namespace=" + nsmgr.LookupNamespace(prefix)))
    Next prefix
Loop While nsmgr.PopScope()

OutputTextBlock.Text = output.ToString()
                // Create the XmlNamespaceManager.
                NameTable nt = new NameTable();
                XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);

                StringBuilder output = new StringBuilder();

                // 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");

                output.AppendLine("Show all the prefix/namespace pairs in the XmlNamespaceManager...");

                do
                {
                    foreach (String prefix in nsmgr)
                    {
                        output.AppendLine("Prefix=" + prefix + " Namespace=" + nsmgr.LookupNamespace(prefix));
                    }
                }
                while (nsmgr.PopScope());

                OutputTextBlock.Text = output.ToString();

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.