Is it possible to parse the XML files from SAX parser without defining the tags name in Java file? I want to make my code generic so that it can parse any kind of XML file rather than some specific XML files.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It sounds like you are looking for XML-to-Object “parser” with externalized mapping (e.g. XML, annotations) or an implied convention. Here’s a list to chose from:
you will sure find more. If you would rather parse your XML by hand using SAX (or DOM, or StAX) then you have to know the names of the XML tags you are interested in. You can abstract them out and make your parser configuration driven but if you are constructing objects from your XML data then your time is better spent picking a framework that can do it for you