Is there a website that will take a sample XML file as input and generate a (rough) Java class based on the elements (not data) in the file? I have a fair-sized XML sample page that I have to do some work with and I'd rather not have to create the Java class representation for it.
If there's not a good online resource, an Eclipse plug-in or Windows-based executable will do as well.
Generate a Java class from an XML Schema using JAXB In the active editor tab, open the desired Schema . xsd file or an XML document, which contains the desired Schema. In the main menu, go to Tools | XML Actions | Generate Java Code From XML Schema Using JAXB.
The class definition contains a name and possibly a <superClass> element and some <attribute> elements. Contains the name of the superclass. Contains the name of the class or of the attribute being defined. Defines an attribute in the current <class>.
Open a command prompt. Run the JAXB schema compiler, xjc command from the directory where the schema file is located. The xjc schema compiler tool is located in the app_server_root \bin\ directory. Use the generated JAXB objects within a Java application to manipulate XML content through the generated JAXB classes.
Just build the maven project using mvn clean install and you will see java classes generated in target/generated-sources/jaxb directory.
I use the one from here:
http://pojo.sodhanalibrary.com/
It creates POJO for XML and JSON inputs
A rather old question, but in case someone comes looking for an alternative to the ones already mentioned, here is one that generates a single file with inner classes
https://codebeautify.org/xml-to-java-converter
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With