Returns the namespace URI for the specified prefix.
var strURI = objNSManager.getURI(prefix);
A string. The namespace URI for the provided prefix.
var oNSMgr; try { oNSMgr = new ActiveXObject("Msxml2.MXNamespaceManager.5.0"); oNSMgr.declarePrefix( "sample", "urn:same uri"); alert(oNSMgr.getURI("sample")); // "urn:same uri" oNSMgr.pushContext(); oNSMgr.declarePrefix ("sample", "urn:new uri"); alert(oNSMgr.getURI("sample")); // "urn:new uri" oNSMgr.popContext(); alert(oNSMgr.getURI("sample")); // "urn:same uri" } catch(e) { alert("Error \n" + e); }
strURI = objNSManager.getURI(prefix)
A variant. The namespace URI for the provided prefix.
Dim oNSEarly As New Msxml2.MXNamespaceManager50 oNSEarly.declarePrefix "sample", "urn:same uri" MsgBox oNSEarly.getURI("sample") ' "urn:same uri" oNSEarly.pushContext oNSEarly.declarePrefix "sample", "urn:new uri" MsgBox oNSEarly.getURI("sample") ' "urn:new uri" oNSEarly.popContext MsgBox oNSEarly.getURI("sample") ' "urn:same uri" If strURI <> Null Then MsgBox strURI End If
HRESULT getURI( BSTR prefix, VARIANT* uri);
An error is raised if a prefix is not declared, or is invalid. This method does not change the current context or stack.
The prefix "xml" is always considered declared, and is permanently bound to "http://www.w3.org/XML/1998/namespace"
.
The prefix "xmlns" is used only for namespace bindings, and is not itself bound to any namespace name. For prefix "xmlns", getURI()
returns S_FALSE, because it is not bound to any namespace.
In the following table, the first column shows the sequence of namespace declarations in an XML document. The second and third columns show the requesting prefixes and return values of the getURI
method.
Declarations | Requesting prefixes | Returns |
---|---|---|
Start of the file | ||
getURI "xml" | S_OK, VT_BSTR("http//…") | |
getURI "abc" | S_FALSE, VT_NULL | |
getURI "" | S_FALSE, VT_NULL | |
getURI "xmlns" | S_FALSE, VT_NULL | |
getURI "cdf" | S_FALSE, VT_NULL | |
getDeclaredPrefixes | ("xml") | |
xmlns="urn://1" | ||
xmlns:abc="urn://2" | ||
getURI "xml" | S_OK, VT_BSTR("http//…") | |
getURI "abc" | S_OK, VT_BSTR("urn://2") | |
getURI "" | S_OK, VT_BSTR("urn://1") | |
getURI "xmlns" | S_FALSE, VT_NULL | |
getURI "cdf" | S_FALSE, VT_NULL | |
getDeclaredPrefixes | ("abc", "", "xml") | |
xmlns="" | ||
getURI "xml" | S_OK, VT_BSTR("http//…") | |
getURI "abc" | S_OK, VT_BSTR("urn://2") | |
getURI "" | S_FALSE, VT_NULL | |
getURI "xmlns" | S_FALSE, VT_NULL | |
getURI "cdf" | S_FALSE, VT_NULL | |
getDeclaredPrefixes | ("abc", "xml") |
Applies to: IVBMXNamespaceManager