SAX Parser without defining tags in Java

java, parsing, sax, xml

Solution

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:

- XStream

- XMLBeans

- JAXB

- JiBX

- Digester

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

Problem

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.

Original source