Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Remove Empty Nodes From Dom document (See related posts)

// Snippit to remove an empty node from the document.
// Node node contains the node (or whole DOM document) from which you want to remove.
// String nameToRemove is the name of the Node you want to remove.

	private static void removeEmptyNodes(Node node, String nameToRemove) {
		NodeList nodeList = node.getChildNodes();
		for(int i=0; i < nodeList.getLength(); i++){
			Node childNode = nodeList.item(i);
			String nodeName = childNode.getNodeName(); 
			if(nodeName.equals(nameToRemove) && childNode.getTextContent().equals("")){
				childNode.getParentNode().removeChild(childNode);
				i--;

			}
			removeEmptyNodes(childNode, nameToRemove);
		}
	}

Comments on this post

lydiafuller83 posts on Feb 05, 2012 at 06:47
In contrast, if you end up still asking, does flex seal really do the job? Then simply you can easily proceed and also see the video demo which is accessible by the net. The movie plainly reveals exactly how an individual utilizes where to buy flex seal and it shows precisely how powerful it might be. An individual can undoubtedly furthermore focus on different web-sites which are usually connected and discover the answers on how Flex Seal actually functions.

You need to create an account or log in to post comments to this site.


Click here to browse all 7716 code snippets

Related Posts