Partager via


IXMLDOMNotation

 

Contains a notation declared in the document type definition (DTD) or schema.

The C/C++ example below displays the names of the notation nodes in the DTD declaration of the document.

The following XML document was used.

<?xml version='1.0'?>  
<!DOCTYPE COLLECTION [   
<!NOTATION XLS PUBLIC "https://www.microsoft.com/office/excel/">  
<!ELEMENT COLLECTION    (DATE? , BOOK+) >  
<!ATTLIST COLLECTION  
    xmlns:dt CDATA #FIXED "urn:schemas-microsoft-com:datatypes">  
<!ELEMENT BOOK(TITLE, AUTHOR, PUBLISHER) >  
<!ELEMENT DATE(#PCDATA) >  
<!ELEMENT TITLE         (#PCDATA)  >  
<!ELEMENT AUTHOR        (#PCDATA)  >  
<!ELEMENT PUBLISHER     (#PCDATA)  >  
]>  
<COLLECTION  
   xmlns:dt="urn:schemas-microsoft-com:datatypes">  
  <BOOK>  
    <TITLE>Lover Birds</TITLE>  
    <AUTHOR>Cynthia Randall</AUTHOR>  
    <PUBLISHER>Lucerne Publishing</PUBLISHER>  
  </BOOK>  
  <BOOK>  
    <TITLE>The Sundered Grail</TITLE>  
    <AUTHOR>Eva Corets</AUTHOR>  
    <PUBLISHER>Lucerne Publishing</PUBLISHER>  
  </BOOK>  
  <BOOK>  
    <TITLE>Splish Splash</TITLE>  
    <AUTHOR>Paula Thurman</AUTHOR>  
    <PUBLISHER>Scootney</PUBLISHER>  
  </BOOK>  
</COLLECTION>  
  
#include “msxml6.h”  
  
inline void TESTHR( HRESULT _hr )   
   { if FAILED(_hr) throw(_hr); }  
  
void XMLDOMNotationSample()  
{  
   try  
   {  
      IXMLDOMDocumentPtr docPtr;  
  
      //init  
      TESTHR(CoInitialize(NULL));   
      TESTHR(docPtr.CreateInstance(_T("Msxml2.DOMDocument.6.0")));  
  
      // load a document  
      _variant_t varXml(("book1.xml"));  
      _variant_t varOut((bool)TRUE);  
      varOut = docPtr->load(varXml);  
      if ((bool)varOut == FALSE)  
      {// show error description - IXMLDOMParseError sample  
         IXMLDOMParseErrorPtr errPtr = docPtr->GetparseError();  
  
      // display eror information  
      }  
      else  
      {  
         IXMLDOMDocumentTypePtr docTypPtr = docPtr->doctype;  
         if (docTypPtr)  
         {  
            int nCounter;  
            IXMLDOMNamedNodeMapPtr XMLDOMNamedNodeMapPtr =   
docTypPtr->Getnotations();  
  
            for(nCounter=0;nCounter < XMLDOMNamedNodeMapPtr->length; nCounter ++)  
            {  
               IXMLDOMNotationPtr XMLDOMNotationPtr =   
XMLDOMNamedNodeMapPtr->Getitem(nCounter);  
  
               _tprintf(_T("%s"), (TCHAR*)XMLDOMNotationPtr->nodeName);  
            }  
         }  
      }  
  
   }  
   catch (_com_error &e)  
   {  
      _tprintf(_T("Error:\n"));  
      _tprintf(_T("Code = %08lx\n"), e.Error());  
      _tprintf(_T("Code meaning = %s\n"), (TCHAR*) e.ErrorMessage());  
      _tprintf(_T("Source = %s\n"), (TCHAR*) e.Source());  
      _tprintf(_T("Error Description = %s\n"), (TCHAR*) e.Description());  
   }  
      catch(...)  
   {  
      _tprintf(_T("Unknown error!"));  
   }  
   CoUninitialize();  
}  
<snippet id="c8a52e5d-3582-4c1d-8deb-e55be28ee9a8"  type="end" />  

Remarks

Notations identify by name the format of unparsed entities, the format of elements that bear a notation attribute, or the application to which a processing instruction is addressed.

The nodeName property contains the notation name.

Requirements

Implementation:

msxml3.dll, msxml2.lib (MSXML 3.0)

msxml6.dll, msxml6.lib (MSXML 6.0)

Header and IDL files:

msxml2.h, msxml2.idl, , msxml6.h, msxml6.idl

Versioning

Implemented in:

MSXML 3.0, MSXML 6.0

See Also

nodeName Property1
IXMLDOMNode
IXMLDOMNotation Members