hasFeature Method

MSXML 5.0 SDK

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

hasFeature Method

Indicates support for the specified feature.

[Script]

Script 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.5.0");
var bool = xmlDoc.implementation.hasFeature("DOM", "1.0");
alert(bool);
[Visual Basic]

Visual Basic 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

Dim xmlDoc As New Msxml2.DOMDocument50
Dim bool As Boolean
bool = xmlDoc.implementation.hasFeature("DOM", "1.0")
MsgBox bool
[C/C++]

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.

C/C++ Return Values

S_OK
The value returned if successful.

C/C++ 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.

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

Applies to: IXMLDOMImplementation