Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.



Used to quote or escape blocks of text to keep that text from being interpreted as markup language.

Although the IXMLDOMCDATASection inherits IXMLDOMText, unlike text nodes, the normalize method of IXMLDOMElement does not merge CDATASection nodes.

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.6.0");
var nodeCDATA;
nodeCDATA = xmlDoc.createCDATASection("Hello");

#import "msxml6.dll"
using namespace MSXML2;

inline void TESTHR( HRESULT _hr ) 
   { if FAILED(_hr) throw(_hr); }

void XMLDOMCDATASectionSample()
   try {
      IXMLDOMDocumentPtr docPtr;
      IXMLDOMNodePtr DOMNodePtr;


      // load a document
      _variant_t varXml("C:\\book.xml");
      _variant_t varOut((bool)TRUE);
      varOut = docPtr->load(varXml);
      if ((bool)varOut == FALSE)
      MessageBox(NULL, _bstr_t(docPtr->xml), _T("Original Document"), MB_OK);

      DOMNodePtr = docPtr->createCDATASection("<fragment>XML tags 
inside a CDATA section</fragment>");

      MessageBox(NULL, _bstr_t(docPtr->xml), _T("New Document"), MB_OK);

   } catch(...)
      MessageBox(NULL, _T("Exception occurred"), _T("Error"), MB_OK);


CDATA sections let you include material such as XML fragments within XML documents without needing to escape all the delimiters. The only delimiter recognized in a CDATA section is the "]]>" string that ends the CDATA section.

CDATA sections cannot be nested.

The text contained by the CDATA section is stored in a text node. This text can contain characters that need to be escaped outside of CDATA sections.

IXMLDOMCDATASection has no unique members of its own, but exposes the same members as the IXMLDOMText object.


msxml3.dll, msxml2.lib (MSXML 3.0)

msxml6.dll, msxml6.lib (MSXML 6.0)

Header and IDL files (C/C++): msxml2.h, msxml2.idl, msxml6.h, msxml6.idl

Implemented in: MSXML 3.0, MSXML 6.0

© 2016 Microsoft