ZVON > References > DOM1 Reference

normalize (method)

Owning interface and usage:  
Element.normalize()

Member of these other interfaces :  
none

Description:  
Puts all Text nodes in the full depth of the sub-tree underneath this Element into a "normal" form where only markup (e.g., tags, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are no adjacent Text nodes. This can be used to ensure that the DOM view of a document is the same as if it were saved and re-loaded, and is useful when operations (such as XPointer lookups) that depend on a particular document tree structure are to be used.

Parameters:  
none

Returns:  
nothing

Exceptions:  
none


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