function remove_phantom_nodes(xml){
	if(xml.nodeType != 8){
		for(var i = xml.childNodes.length-1; i >= 0; i--){
			var obj = xml.childNodes[i];
			//not valid xml if contains both text and non-text nodes, remove text nodes (Gecko-based browsers will have this)
			if(obj.nodeType == 3 && containsOnlyWhitespace(escape(obj.nodeValue)))
				xml.removeChild(obj);
			else
				remove_phantom_nodes(obj);
		}
	}
}

function containsOnlyWhitespace(string){
	var re1 = new RegExp(/%0A/);
	var re2 = new RegExp(/%09/);
	var re3 = new RegExp(/%20/);
	var m;
	while(m = re1.exec(string))
		string = string.replace(string.substring(m.index,m.index+3),'');
	while(m = re2.exec(string))
		string = string.replace(string.substring(m.index,m.index+3),'');
	while(m = re3.exec(string))
		string = string.replace(string.substring(m.index,m.index+3),'');
	return string.length == 0;
}
	
function traverseTextNodes(){
	var body = document.getElementsByTagName('body');
	remove_phantom_nodes(body[0]);
	displayTextNode(body[0]);
}

function displayTextNode(xml){
	/*if(xml.nodeType != 8){
		for(var i = xml.childNodes.length-1; i >= 0; i--){
			var obj = xml.childNodes[i];
			if(obj.nodeName != 'INPUT'){
				if(obj.nodeType == 3){
					var re1 = new RegExp(/Ohio/);
					var m;
					while(m = re1.exec(obj.nodeValue)){
						obj.nodeValue = obj.nodeValue.replace(obj.nodeValue.substring(m.index+1,m.index+4),'***');
					}
					//alert(obj.nodeName + ': ' + obj.nodeValue);
				}
				else{
					//alert(obj.nodeName);
					displayTextNode(obj);
				}
			}
		}
	}*/
}
