XmlNamespaceManager Constructor
Collapse the table of content
Expand the table of content

XmlNamespaceManager Constructor

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

Initializes a new instance of the XmlNamespaceManager class with the specified XmlNameTable.

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

'Declaration
Public Sub New ( _
	nameTable As XmlNameTable _
)

Parameters

nameTable
Type: System.Xml.XmlNameTable
The XmlNameTable to use.

ExceptionCondition
NullReferenceException

nameTableis Nothing.

The name table is used to look up prefixes and namespaces. An existing name table with pre-atomized strings can be specified in the constructor. There are several advantages in doing so. For example, if the name table of an XmlReader object is used, after each read, any namespace and prefix strings pushed into the name table can be re-used by XmlNamespaceManager.

For more information on atomized strings, see XmlNameTable.

NoteNote:

If you specify an existing name table, any namespaces in the name table are not automatically added to XmlNamespaceManager. You must use AddNamespace and RemoveNamespace to add or remove namespaces.


Dim output As New StringBuilder()

Dim xmlFrag As String = _
      "<root>" & _
        "<data>" & _
         "<items>" & _
          "<item id='1'>" & _
          "</item>" & _
         "</items>" & _
        "</data>" & _
        "</root>"

Using reader As XmlReader = XmlReader.Create(New StringReader(xmlFrag))
    Dim nsmanager As New XmlNamespaceManager(reader.NameTable)
    nsmanager.AddNamespace("msbooks", "www.microsoft.com/books")
    nsmanager.PushScope()
    nsmanager.AddNamespace("msstore", "www.microsoft.com/store")

    Dim prefix As String
    For Each prefix In nsmanager
        output.AppendLine(("Prefix" + prefix + _
                           " Namespace=" + nsmanager.LookupNamespace(prefix)))
    Next prefix
End Using
OutputTextBlock.Text = output.ToString()


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft