Set ksmContent.ignoreWhite = false; to true. Otherwise all the white space is counted as nodes.