ещё вариант ))) ...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script language="JavaScript" type="text/javascript">
domNormalize = function (c) {
var d = c.innerHTML;
(function (e) {
for (var b = e.childNodes, a = b.length - 1; a >= 0; a--) {
b[a].hasChildNodes() && arguments.callee(b[a]);
b[a].nodeType == 3 && /^\s+$/.test(b[a].data) && b[a].parentNode.removeChild(b[a])
}
})(c);
alert(d + "\n" + c.innerHTML)
};
window.onload=function(){domNormalize(document.body);};
</script>
</head>
<body>
<div> <div> <p> </p> <p> </p> </div> </div> 123
</body>
</html>