pushContext Method

 

[This feature was first implemented for MSXML 4.0.]

Pushes the local context down the stack.

Script Syntax

objNSManager.pushContext();  

Parameters

None.

Example

var oNSMgr;

try
{
   oNSMgr = new ActiveXObject("Msxml2.MXNamespaceManager.6.0");
   oNSMgr.declarePrefix( "sample", "urn:same uri");
   WScript.Echo(oNSMgr.getURI("sample"));
   oNSMgr.pushContext();
   oNSMgr.declarePrefix ("sample", "urn:new uri");
   WScript.Echo(oNSMgr.getURI("sample"));
   oNSMgr.popContext();
   WScript.Echo(oNSMgr.getURI("sample"));
} catch(e)
{
   WScript.Echo("Error \n" + e);
}

Output

urn:same uri  
urn:new uri  
urn:same uri  

Visual Basic Syntax

objNSManager.pushContext  

Parameters

None.

Example

Dim oNSMgr As New Msxml2.MXNamespaceManager60
oNSMgr.declarePrefix "sample", "urn:same uri"
MsgBox oNSMgr.getURI("sample")
oNSMgr.pushContext
oNSMgr.declarePrefix "sample", "urn:new uri"
MsgBox oNSMgr.getURI("sample")
oNSMgr.popContext
MsgBox oNSMgr.getURI("sample")

Output

urn:same uri  
urn:new uri  
urn:same uri  

C/C++ Syntax

HRESULT pushContext();  

Parameters

None.

Return Values

S_OK
The value returned if successful.

Example

MSXML2::IMXNamespaceManagerPtr PtrIMXNamespaceManager;
   HRESULT hres;
   unsigned short WideCharBuffer[100];
   int BufferLength = 100;

   try
   {
      PtrIMXNamespaceManager.CreateInstance( _
                              __uuidof(MSXML2::MXNamespaceManager));
      PtrIMXNamespaceManager->declarePrefix(_T("sample"),_T("urn"));
      
      hres = PtrIMXNamespaceManager->_getURI(L"sample", NULL, _
                                             WideCharBuffer, _
                                             &BufferLength);
      DisplayMessageToUser(_bstr_t(WideCharBuffer));

      PtrIMXNamespaceManager->pushContext();

      PtrIMXNamespaceManager->declarePrefix(_T("sample"),_T("urn2"));
      
      BufferLength = 100;
      hres = PtrIMXNamespaceManager->_getURI(L"sample", _
                                             NULL, _
                                             WideCharBuffer, _
                                             &BufferLength);
      DisplayMessageToUser(_bstr_t(WideCharBuffer));

      PtrIMXNamespaceManager->popContext();

      BufferLength = 100;
      hres = PtrIMXNamespaceManager->_getURI(L"sample", _
                                             NULL, _
                                             WideCharBuffer, _
                                             &BufferLength);
      DisplayMessageToUser(_bstr_t(WideCharBuffer));
   }
   catch(...)
   {
      DisplayMessageToUser("Error");
   }
}

void DisplayMessageToUser(char *Msg)
{
   ::MessageBox(NULL, Msg, _T("Message"), MB_OK);
}

Remarks

The pushContext method pushes the local context down the stack, and creates a new local context.

Versioning

Implemented in: MSXML 4.0 and later

Applies to

IVBMXNamespaceManager

IMXNamespaceManager