共用方式為


entities Property

 

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

Script Syntax

var objXMLDOMNamedNodeMap = oXMLDOMDocumentType.entities;  

Visual Basic Syntax

Set objXMLDOMNamedNodeMap = oXMLDOMDocumentType.entities  

C/C++ Syntax

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; 
}

Remarks

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">         
]>         

Versioning

Implemented in: MSXML 3.0, MSXML 6.0

Applies to

IXMLDOMDocument-DOMDocument