getNamespace

open fun getNamespace(prefix: String): String?

Returns the URI corresponding to the given prefix, depending on current state of the parser.

If the prefix was not declared in the current scope, null is returned. The default namespace is included in the namespace table and is available via getNamespace(null).

This method is a convenience method for

for (int i = getNamespaceCount(getDepth ())-1; i >= 0; i--) {
if (getNamespacePrefix(i).equals( prefix )) {
return getNamespaceUri(i);
}
}
return null;

Please note: parser implementations may provide more efficient lookup, e.g. using a Hashtable. The 'xml' prefix is bound to "http://www.w3.org/XML/1998/namespace", as defined in the Namespaces in XML specification. Analogous, the 'xmlns' prefix is resolved to http://www.w3.org/2000/xmlns/

See also