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.
-
3A SAX Parser is a generic XML parser already. What do you really want to do?JB Nizet– JB Nizet2012-05-26 16:50:59 +00:00Commented May 26, 2012 at 16:50
-
Yes, of course it's possible. However, it rather depends on what you want your application to do with the output from the SAX parser.Michael Kay– Michael Kay2012-05-27 18:45:25 +00:00Commented May 27, 2012 at 18:45
-
What solution are you using to parse xml?MaNn– MaNn2018-02-08 10:06:34 +00:00Commented Feb 8, 2018 at 10:06
Add a comment
|
2 Answers
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
1 Comment
Black Mask
Thank you Pravel Veller for the answer.