entities Property

 

Contains a list of the entities declared in the <!DOCTYPE> declaration.

var objXMLDOMNamedNodeMap = oXMLDOMDocumentType.entities;  

Set objXMLDOMNamedNodeMap = oXMLDOMDocumentType.entities  

HRESULT get_entities(  
    IXMLDOMNamedNodeMap **entityMap);  

Parameters

entityMap[out, retval]
A list of the general entities, both external and internal, that are present in this document.

C/C++ Return Values

S_OK
The value returned if successful.

E_INVALIDARG
The value returned if the entityMap parameter is Null.

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 when finished using it.
  return pIXMLDOMEntity; 
}

The property is read-only. In the following DOCTYPE declaration, for example, the node list in this property contains the entities "bat" and "bar".

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

Implemented in: MSXML 3.0, MSXML 6.0

IXMLDOMDocument-DOMDocument

Show: