ZVON > References > DOM2 Reference

normalize (method )

Owning interface and usage:  
Node.normalize()

Member of these other interfaces:  
Attr, CDATASection, CharacterData, Comment, Document, DocumentFragment, DocumentType, Element, Entity, EntityReference, Notation, ProcessingInstruction, Text

Description:  
Puts all Text nodes in the full depth of the sub-tree underneath this node, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes.

Parameters:  
none

Returns:  
nothing

Exceptions:  
none

Note:  


Example:
Source:
  <div id="doc"></div>
JavaScript:
  var main = document.getElementById('doc');
  var output1 = main.childNodes.length;
  var textNode1 = document.createTextNode('This is some text.');
  var textNode2 = document.createTextNode('This is another text.');
  main.appendChild(textNode1);
  main.appendChild(textNode2);
  var output2 = main.childNodes.length;
  main.normalize();
  var output3 = main.childNodes.length;
Output:
desired your browser
output1: 0
output2: 2
output3: 1