Freigeben über


hasFeature Method

 

Indicates support for the specified feature.

JScript Syntax

boolVal = objXMLDOMImplementation.hasFeature(feature, version);  

Parameters

feature
A string that specifies the feature to test. In Level 1, valid feature values are "XML", "DOM", and "MS-DOM" (case-insensitive).

version
A string that specifies the version number to test, or if Null, tests for implementation of the feature in any version. In Level 1, "1.0" is the valid version value.

Return Value

Boolean. Returns True if the specified feature is implemented; otherwise False.

Example

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.6.0");
var bool = xmlDoc.implementation.hasFeature("DOM", "1.0");
WScript.Echo(bool);

Output

-1

C/C++ Syntax

HRESULT hasFeature(  
    BSTR feature,  
    BSTR version,  
    VARIANT_BOOL *hasFeature);  

Parameters

feature [in]
The feature to test. In Level 1, valid feature values are "XML", "DOM", and "MS-DOM" (case-insensitive).

version [in]
The version number to test, or, if Null, tests for implementation of the feature in any version. In Level 1, "1.0" is the only valid version value.

hasFeature [out, retval]
True if the specified feature is implemented; otherwise False.

Return Values

S_OK
The value returned if successful.

Example

IXMLDOMImplementation *pIXMLDOMImplementation = NULL;  
VARIANT_BOOL varbFlag ;  
BSTR bstrOutput = NULL;  
BSTR bstrFeature = ::SysAllocString(_T("MS-DOM"));  
HRESULT hr;  
IXMLDOMDocument *pIXMLDOMDocument = NULL;  
  
try  
{  
   // Create an instance of DOMDocument and initialize pIXMLDOMDocument.  
   // Load/create an XML fragment.  
   hr = pIXMLDOMDocument->get_implementation(&pIXMLDOMImplementation);  
  
   if(SUCCEEDED(hr) && pIXMLDOMImplementation)  
   {  
      hr = pIXMLDOMImplementation->hasFeature(bstrFeature, _T("1.0"), &varbFlag);  
      if(varbFlag == VARIANT_TRUE )  
         bstrOutput = ::SysAllocString(_T("Feature Supported"));  
      else  
         bstrOutput = ::SysAllocString(_T("Feature not Supported"));  
  
      ::MessageBox(NULL, bstrOutput, bstrFeature, MB_OK);  
      ::SysFreeString(bstrOutput);  
      bstrOutput = NULL;  
      ::SysFreeString(bstrFeature);  
      bstrFeature = NULL;  
      pIXMLDOMImplementation->Release();  
   }  
}  
catch(...)  
{  
   if(bstrOutput)  
      ::SysFreeString(bstrOutput);  
   if(bstrFeature)  
      ::SysFreeString(bstrFeature);  
   if(pIXMLDOMImplementation)  
      pIXMLDOMImplementation->Release();  
   DisplayErrorToUser();  
}  
// Release pIXMLDOMDocument when finished using it.  

Versioning

Implemented in: MSXML 3.0 and MSXML 6.0

See Also

IXMLDOMImplementation