It's not a 100% sure thing, but AFIK
you should implement the ErrorHandler interface. It should return you the line number on which the error occured.
You set it like this
aDocumentBuilder.setErrorHandler(new anErrorHandler);
It has 3 methods to be implemented and should do the trick.