DOM Nodes with empty TEXT NODE

Posted in C/C++ LANGUAGE, PROGRAMMING by edeguzman on February 13, 2012

In most cases DOM nodes can probably contain empty TEXT nodes for the reason that you read from file and tabs or spaces are being preserved in element nodes. This empty TEXT nodes sometimes a troublesome whenever you have an operation like you want to traverse to each child element nodes and do some process but suddenly the traversing to child nodes stop because of this empty TEXT node.

 I tried to google around to find a faster why to remove this empty TEXT nodes because I was hoping that there’s just an API call in DOM object that will automatically remove all empty TEXT nodes without affecting the child element nodes. I saw a lot of people encounter the same issue but provided complicate solution like using XSL. Then I decided to code it myself,  I was able to code it in 15 minutes in C++,  and I was googling around for about 1.5 hours 😦   Now after awhile I work on the servlet side then I’d encountered the same dilemma this time in Java.  This is the reason why I decided to share part of my code, just in case if someone might stumble in this dilemma.

Read more about this article in the below URL.