function writeStringTextNode(node, string) {
  if (
    typeof string === 'string' &&
    (whiteSpaceStart.test(string) ||
      whiteSpaceEnd.test(string) ||
      cdataCharacters.test(string))
  ) {
    string.split(']]>').forEach((part, i, a) => {
      if (i < a.length - 1) {
        part += ']]';
      }
      if (i > 0) {
        part = '>' + part;
      }
      writeCDATASection(node, part);
    });
  } else {
    node.appendChild(getDocument().createTextNode(string));
  }
}
@param {Node} node Node to append a TextNode with the string to.
@param {string} string String.