createTextNode (DOMDocument - JavaScript)

Creates a text node.

Defined in

DOMDocument

Syntax

createTextNode(data:string) : DOMText
Parameters Description
data The content of the text node.
Return value Description
DOMText The text node.

Usage

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

You can also create a text node by setting the value of an element, for example, with setStringValue (DOMDocument - JavaScript).

Examples

This button creates a document with a hierarchy of elements where the last element contains a text node.
var doc = database.createNewDocument();
var dom = doc.getDOM();
var schema0 = dom.createElement("schema0");
var element0 = dom.createElement("element0");
var text0 = dom.createTextNode(requestScope.s);
dom.appendChild(schema0);
schema0.appendChild(element0);
element0.appendChild(text0);
doc.save()
The XML appears as follows if requestScope.s is foo:
<schema0>
	<element0>foo</element0>
</schema0>