createComment (DOMDocument - JavaScript)

Creates a comment node.

Defined in

DOMDocument

Syntax

createComment(data:string) : DOMComment
Parameters Description
data The text of the comment.
Return value Description
DOMComment The comment.

Usage

This method does not place the node in the DOM. You must, for example, append the node with appendChild in DOMNode.

Examples

This button creates a document with a hierarchy of elements and comments.
var doc = database.createNewDocument();
var dom = doc.getDOM();
var schema0 = dom.createElement("schema0");
var element0 = dom.createElement("element0");
dom.appendChild(dom.createComment("DOM comment"));
dom.appendChild(schema0);
schema0.appendChild(dom.createComment("Schema comment"));
schema0.appendChild(element0);
element0.setStringValue(requestScope.s);
element0.appendChild(dom.createComment("Element comment"));
doc.save()
The XML for this document might appear as follows:
<!--DOM comment-->
<schema0>
  <!--Schema comment-->
  <element0>foo
    <!--Element comment-->
  </element0>
</schema0>