XmlNamespaceManager.PushScope Method

Pushes a namespace scope onto the stack.

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

public virtual void PushScope()

After a call to this method, all namespaces, which are added to XmlNamespaceManager (by calling AddNamespace), belong to the pushed namespace scope.

                StringBuilder output = new StringBuilder();

                // Create the string containing the XML to read.
                String xmlFrag =
		                        <item id='1'>

                using (XmlReader reader = XmlReader.Create(new StringReader(xmlFrag)))
                    XmlNamespaceManager nsmanager = new XmlNamespaceManager(reader.NameTable);
                    nsmanager.AddNamespace("msbooks", "www.microsoft.com/books");
                    nsmanager.AddNamespace("msstore", "www.microsoft.com/store");

                    foreach (String prefix in nsmanager)
                        output.AppendLine("Prefix" + prefix + " Namespace=" +
                OutputTextBlock.Text = output.ToString();


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

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

Community Additions