Name: stripEmptyNodes() - removes text nodes which are white space
Author: senocular: www.senocular.com
Date: 1899-12-31T00:33:03.200
Documentation:
XML (XMLNode) STRIPEMPTYNODES: takes an existing XML
object, cycles through its nodes and removes any nodes
(text nodes) which contain only whitespace.
Arguments:
none
Returns:
nothing
Example:
test_xml = new XML(" \t \n \r\n \n ");
trace("== Before: =============\n" + test_xml + "\n========================\n\n");
test_xml.stripEmptyNodes();
trace("== After: =============\n" + test_xml + "\n========================");
outputs:
== Before: =============
========================
== After: =============
========================
1
2
3
4
5
XMLNode.prototype.stripEmptyNodes = function(){
this.nextSibling.stripEmptyNodes();
if (!isNaN(this+" 0")) this.removeNode();
else if (this.childNodes.length) this.firstChild.stripEmptyNodes();
}