Microsoft XML 2.5 SDK


 

IXMLDOMDocumentType::get_entities Method

[This is preliminary documentation and subject to change.]

Contains a list of the entities declared in the document type declaration.

Visual Basic Syntax

Set objXMLDOMNamedNodeMap = oXMLDOMDocumentType.entities

C/C++ Syntax

HRESULT get_entities(

    IXMLDOMNamedNodeMap **entityMap);

Parameters

entityMap

[out]
List of the general entities, both external and internal, that are present in this document.

C/C++ Return Values

S_OK

Value returned if successful.

E_INVALIDARG

Value returned if entityMap is null.

Remarks

In the following document type declaration, for example, the node list in this property contains the entities "bat" and "bar" but not "baz".

<!DOCTYPE ex SYSTEM "ex.dtd" [
  <!ENTITY bat "bat">
  <!ENTITY bar "bar">
  <!ENTITY % baz "baz">
]>

C/C++ Example

IXMLDOMEntity *GetRootEntity()
{
   HRESULT hr;
   IXMLDOMNamedNodeMap *pIXMLDOMNamedNodeMapEntities = NULL;
   IXMLDOMEntity *pIXMLDOMEntity = NULL;
   IXMLDOMNode *pIXMLDOMNode = NULL;
IXMLDOMDocument *pIXMLDOMDocument = NULL;
IXMLDOMDocumentType *pIXMLDOMDocumentType = NULL;

   try
   {
      // create an instance of DOMDocument and initialize pIXMLDOMDocument
      // load/create an XML fragment
      hr = pIXMLDOMDocument->get_doctype(&pIXMLDOMDocumentType);
      SUCCEEDED(hr) ? 0 : throw hr;

      if(pIXMLDOMDocumentType)
      {
hr = pIXMLDOMDocumentType->get_entities (&pIXMLDOMNamedNodeMapEntities);
         if(SUCCEEDED(hr) && pIXMLDOMNamedNodeMapEntities)
         {
            hr = pIXMLDOMNamedNodeMapEntities->nextNode(&pIXMLDOMNode);
            if(SUCCEEDED(hr) && pIXMLDOMNode)
            {
hr = pIXMLDOMNode->QueryInterface(IID_IXMLDOMEntity, (void**)&pIXMLDOMEntity );
               SUCCEEDED(hr) ? 0 : throw hr;
pIXMLDOMNode->Release();
               pIXMLDOMNode = NULL;
            }
         pIXMLDOMNamedNodeMapEntities->Release();
         }
      pIXMLDOMDocumentType->Release();
      }
   }
   catch(...)
   {
      if(pIXMLDOMNode)
         pIXMLDOMNode->Release();
      DisplayErrorToUser();
   }

   // Release pIXMLDOMEntity after finished using it.
   return pIXMLDOMEntity; 
}