Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class System.​Xml.​XmlNamespaceManager
Assembly: System.Xml.ReaderWriter
Inheritance: object → XmlNamespaceManager
Implemented Interfaces
Resolves, adds, and removes namespaces to a collection and provides scope management for these namespaces.
Properties
public
string
DefaultNamespace
Gets the namespace URI for the default namespace.
public
XmlNameTable
NameTable
Gets the <see cref="T:System.Xml.XmlNameTable" /> associated with this object.
Methods
public
void
AddNamespace​(string prefix,
string uri)
Adds the given namespace to the collection.
prefix
The prefix to associate with the namespace being added. Use String.Empty to add a default namespace.
Note If the <see cref="T:System.Xml.XmlNamespaceManager" /> will be used for resolving namespaces in an XML Path Language (XPath) expression, a prefix must be specified. If an XPath expression does not include a prefix, it is assumed that the namespace Uniform Resource Identifier (URI) is the empty namespace. For more information about XPath expressions and the <see cref="T:System.Xml.XmlNamespaceManager" /> , refer to the <see cref="M:System.Xml.XmlNode.SelectNodes(System.String)" /> and <see cref="M:System.Xml.XPath.XPathExpression.SetContext(System.Xml.XmlNamespaceManager)" /> methods.
uri
The namespace to add.
GetEnumerator​()
Returns an enumerator to use to iterate through the namespaces in the <see cref="T:System.Xml.XmlNamespaceManager" /> .
Returns An <see cref="T:System.Collections.IEnumerator" /> containing the prefixes stored by the <see cref="T:System.Xml.XmlNamespaceManager" /> .
public
Collections.​Generic.​IDictionary<​string, string>
GetNamespacesInScope​(XmlNamespaceScope scope)
Gets a collection of namespace names keyed by prefix, which can be used to enumerate the namespaces currently in scope.
Returns A collection of namespace and prefix pairs currently in scope.
scope
An enumeration value that specifies the type of namespace nodes to return.
public
bool
HasNamespace​(string prefix)
Gets a value indicating whether the supplied prefix has a namespace defined for the current pushed scope.
Returns <see langword="true" /> if there is a namespace defined; otherwise, <see langword="false" /> .
prefix
The prefix of the namespace you want to find.
public
string
LookupNamespace​(string prefix)
Gets the namespace URI for the specified prefix.
Returns The namespace URI for <paramref name="prefix" /> or <see langword="null" /> if there is no mapped namespace. The returned string is atomized.
For more information on atomized strings, see the <see cref="T:System.Xml.XmlNameTable" /> class.
prefix
The prefix whose namespace URI you want to resolve. To match the default namespace, pass String.Empty.
public
string
LookupPrefix​(string uri)
Finds the prefix declared for the given namespace URI.
Returns The matching prefix. If there is no mapped prefix, the method returns String.Empty. If a null value is supplied, then <see langword="null" /> is returned.
uri
The namespace to resolve for the prefix.
public
bool
PopScope​()
Pops a namespace scope off the stack.
Returns <see langword="true" /> if there are namespace scopes left on the stack; <see langword="false" /> if there are no more namespaces to pop.
public
void
PushScope​()
Pushes a namespace scope onto the stack.
public
void
RemoveNamespace​(string prefix,
string uri)
Removes the given namespace for the given prefix.
prefix
The prefix for the namespace.
uri
The namespace to remove for the given prefix. The namespace removed is from the current namespace scope. Namespaces outside the current scope are ignored.
public
bool
Equals​(object obj)
Inherited from object
protected
void
Finalize​()
Inherited from object
public
int
GetHashCode​()
Inherited from object
protected
object
MemberwiseClone​()
Inherited from object
public
string
ToString​()
Inherited from object