getURI Method
Returns the namespace URI for the specified prefix.
Script Syntax
var strURI = objNSManager.getURI(prefix);
Parameters
- prefix
- The prefix bound to the specified namespace URI.
Return Values
A string. The namespace URI for the provided prefix.
Example
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); }
Visual Basic Syntax
strURI = objNSManager.getURI(prefix)
Parameters
- prefix
- The prefix bound to the specified namespace URI.
Return Values
A variant. The namespace URI for the provided prefix.
Example
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
C/C++ Syntax
HRESULT getURI( BSTR prefix, VARIANT* uri);
Parameters
- prefix[in]
- The prefix bound to the specified namespace URI.
- uri[out,retval]
- The namespace URI for the provided prefix.
C/C++ Return Values
- S_OK
- The value returned if successful.
- E_FAIL
- The value returned if the prefix is not bound to the current context.
- E_POINTER
- The value returned if the last argument is NULL.
Remarks
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