> can anyone tell me how to ignore white spaces and
> related characters when usin dom.
I'm assuming that you're talking about the newlines and spaces from a pretty-printed document, which are showing up in your Text nodes?
The easiest way is to simply call trim() on the string value of the text nodes, and ignore those that are empty afterwards. There is a method on Text, isElementContentWhitespace(), that can be used to determine whether the node contains "ignorable whitespace," but that doesn't help when the node contains non-text characters.
As a caveat, you should pay attention to the [url=http://www.xml.com/axml/target.html#sec-white-space]xml:space[/url] attribute.