popContext Method
Pops the last local context from the top of the stack.
Script Syntax
objNSManager.popContext();
Parameters
None.
Example
var oNSMgr;
try
{
oNSMgr = new ActiveXObject("Msxml2.MXNamespaceManager.6.0");
oNSMgr.declarePrefix( "sample", "urn:same uri");
WScript.Echo(oNSMgr.getURI("sample")); // "urn:same uri"
oNSMgr.pushContext();
oNSMgr.declarePrefix ("sample", "urn:new uri");
WScript.Echo(oNSMgr.getURI("sample")); // "urn:new uri"
oNSMgr.popContext();
WScript.Echo(oNSMgr.getURI("sample")); // "urn:same uri"
} catch(e)
{
WScript.Echo("Error \n" + e);
}
Output
urn:same uri
urn:new uri
urn:same uri
C/C++ Syntax
HRESULT popContext();
Parameters
None.
Return Values
S_OK
The value returned if successful.
E_FAIL
The value returned if no context is available to pop.
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 popContext
method removes all declarations from the top of the stack down to the declaration prior to the last pushContext
method call. If no context is available to pop, popContext
returns an error.
Versioning
Implemented in: MSXML 6.0