Joe's analysis is correct. You can get the behavior that you want by calling setIncludeIgnorableWhitespace with an argument of false which will drop explicit the text nodes for your carriage returns and tabs. parser.setIncludeIgnorableWhitespace(false);