IXMLDOMNotation

MSXML 5.0 SDK

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

IXMLDOMNotation

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

[C/C++]

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

The following document was used.

<?xml version='1.0'?>
<!DOCTYPE COLLECTION [ 
<!NOTATION XLS PUBLIC "http://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>

#import "msxml5.dll"
using namespace MSXML2;

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.5.0")));

      // load a document
      _variant_t varXml(("D:\\xmlSample\\xmlTest\\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();
}

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.

Versioning

MSXML 2.0 and later

Requirements

Implementation: msxml5.dll, msxml2.lib

[C/C++]

Header and IDL files: msxml2.h, msxml2.idl

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

nodeName Property | IXMLDOMNode | IXMLDOMNotation Members