I am a beginner in SAX. I am able to get the error message on the vent of an exception (error or warning). But I want to get the element which caused it. How can that be done?. eg: The error msg shown now is like " Attribute "RollNumber" is required and must be specified for element "StudentDetails". in entity file:///D:/abc/def/classes/abc.xml"
What I want is a method by which I get the element name only ie StudentDetails and the value which is wrong(in case it is a Data Value error).
Welcome to javaranch, please change your display name according to the http://www.javaranch.com/name.jsp policy. ---------- From the error message, it implies to me that your parser has the schema validation turned on. Please chekc whether your xml is valid to your xmlschema first.
If you want the element that caused the parsing exception, I see two options: 1) Use SAXParseException#getLineNumber() and SAXParseException#getColumnNumber() to find out the location of the error and seek out that particular point in the XML file 2) In your handler class, keep count of which element you're "in" at any one time. Then, when you get an exception from parse(), ask the handler object for the name of the last element it entered successfully.