طريقة createCDATASection() لمستند XML DOM

Document object reference manual

التعريف والاستخدام

يمكن للطريقة createCDATASection() إنشاء ميزة CDATASection.

يمكن لهذا الطريقة إرجاع ميزة CDATASection.

النحو:

createCDATASection(data)
المعلمات الوصف
data فالسطر القيم، يمكن لهذا السطر تحديد بيانات هذا العنصر.

Return value

Return the newly created CDATASection node, containing the specified data.

throw

If the document is an HTML document, this method will throw an error code of NOT_SUPPORTED_ERR DOMException exceptionbecause HTML documents do not support CDATASection nodes.

Example

In all examples, we will use the XML file books.xml, and JavaScript functions loadXMLDoc().

The following code snippet can add a CDATA section node to the <book> element:

xmlDoc=loadXMLDoc("books.xml");
var x=xmlDoc.getElementsByTagName('book');
var newCDATA,newtext;
newtext="Special Offer & Book Sale";
for (i=0;i<x.length;i++)
  {
  newCDATA=xmlDoc.createCDATASection(newtext);;
  x[i].appendChild(newCDATA);
  }

Document object reference manual