Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Online resource to generate Java class from XML file [closed]

Tags:

java

xml

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.

like image 355
Haphazard Avatar asked Jun 14 '11 14:06

Haphazard


People also ask

How do you create a Java class from an XML schema?

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.

How do you create a class in XML?

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>.

How do I create a Java class using XJC?

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.

How do I generate Java classes from XSD using JAXB maven?

Just build the maven project using mvn clean install and you will see java classes generated in target/generated-sources/jaxb directory.


2 Answers

I use the one from here:

http://pojo.sodhanalibrary.com/

It creates POJO for XML and JSON inputs

like image 94
Cyril Beschi Avatar answered Oct 11 '22 13:10

Cyril Beschi


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

like image 24
Nacho Mezzadra Avatar answered Oct 11 '22 13:10

Nacho Mezzadra