Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - XML Reference

getDeclaredPrefixes Method

Returns a collection of declared namespace prefixes bound to a namespace name.

[Script]

Script Syntax

var objNSPrefixes = objNSManager.getDeclaredPrefixes();

Parameters

None.

Return Values

An object. Returns the collection of prefixes.

Example

var oNSMgr;
   
   try
   {
      oNSMgr = new ActiveXObject("Msxml2.MXNamespaceManager.5.0");
      oNSMgr.declarePrefix( "sample", "urn");
      oNSMgr.declarePrefix ("a", "abc");
      alert(oNSMgr.getDeclaredPrefixes.length); // 3
      alert(oNSMgr.getDeclaredPrefixes[0]); // "sample"
      alert(oNSMgr.getURI("sample")); // "urn"
      alert(oNSMgr.getPrefixes("urn")[0]); // "sample"
   }catch(e)
   {
      alert("Error \n" + e);
   }

Remarks

The returned collection is never empty. If no prefixes have been declared, the returned collection contains the prefix "xml" (permanently bound to "http://www.w3.org/XML/1998/namespace").

If the URI reference in a default namespace declaration is empty, unprefixed elements in the scope of the declaration are not considered to be in any namespace. This causes the prefix xmlns to be used only for namespace bindings. This prefix is not itself bound to any namespace name.

[Visual Basic]

Visual Basic Syntax

set objNSPrefixes = objNSManager.getDeclaredPrefixes

Parameters

None.

Return Values

An object. Returns the collection of prefixes.

Example

    Dim oNSMgr As New Msxml2.MXNamespaceManager50
    oNSMgr.declarePrefix "sample", "urn"
    oNSMgr.declarePrefix "a", "abc"
    MsgBox oNSMgr.getDeclaredPrefixes.length ' 3
    MsgBox oNSMgr.getDeclaredPrefixes.Item(0) ' "sample"
    MsgBox oNSMgr.getPrefixes("urn").Item(0) ' "sample"
    MsgBox oNSMgr.getURI("sample") ' "urn"

Remarks

The returned collection is never empty. If no prefixes have been declared, the returned collection contains the prefix "xml" (permanently bound to "http://www.w3.org/XML/1998/namespace"). If the URI reference in a default namespace declaration is empty, unprefixed elements in the scope of the declaration are not considered to be in any namespace. This causes the prefix xmlns to be used only for namespace bindings. This prefix is not itself bound to any namespace name.

[C/C++]
HRESULT getDeclaredPrefixes(
    IMXNamespacePrefixes** prefixes);

Parameters

prefixes[out,retval]
The prefixes collection.

C/C++ Return Values

S_OK
The value returned if successful.
E_POINTER
The value returned if the last parameter is NULL.
E_OUTOFMEMORY
The value returned if there is no memory for IMXNamespacePrefixes.

Remarks

The returned collection is never empty. If no prefixes have been declared, the returned collection contains the prefix 'xml' (permanently bound to 'http://www.w3.org/XML/1998/namespace'). If the URI reference in a default namespace declaration is empty, unprefixed elements in the scope of the declaration are not considered to be in any namespace. This causes the prefix xmlns to be used only for namespace bindings. This prefix is not itself bound to any namespace name.

To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

getPrefixes Method | getDeclaredPrefix Method (C++)

Applies to: IVBMXNamespaceManager