--- title: Document.createCDATASection() slug: Web/API/Document/createCDATASection tags: - API - Création - DOM - Document - Méthode - Section - XML - données translation_of: Web/API/Document/createCDATASection ---
{{APIRef("DOM")}}

createCDATASection() crée un nouveau noeud de section CDATA et le renvoie.

Syntaxe

CDATASectionNode = document.createCDATASection(data)

Exemple

var docu = new DOMParser().parseFromString('<xml></xml>',  "application/xml")

var cdata = docu.createCDATASection('Some <CDATA> data & then some');

docu.getElementsByTagName('xml')[0].appendChild(cdata);

alert(new XMLSerializer().serializeToString(docu));
// Affiche : <xml><![CDATA[Some <CDATA> data & then some]]></xml>

Notes

Spécification