Reputation: 1631
How can I convert xml to java so that it could read the xml document and put it in to a database?
Upvotes: 1
Views: 615
Reputation: 111
Use this https://json2csharp.com/xml-to-java in case you're looking for an online tool, you can then deserialize your object and fill it in the database
Upvotes: 0
Reputation: 149047
For this I recommend EclipseLink. EclipseLink offers both JAXB (object-to-XML) and JPA (object-to-Database) support.
The EclipseLink JAXB (MOXy) implementation offers all the extensions you need for mapping JPA entities to XML, for more information see:
Upvotes: 0
Reputation: 43709
Check Hyperjaxb3. It is a JAXB plugin which makes schema-derived classes to JPA entities. Thus you can easily do XML <-(JAXB)-> Java <-(JPA)-> RDB.
Upvotes: 0
Reputation: 133669
It's not clear at all, but if you are talking about parsing a XML file to do whatever you want with it in Java (also storing it in a database) you have to already ready choices:
both are covered here just to give you an example, but check documentation for better explaination.
Upvotes: 1
Reputation: 52400
It sounds like you are looking for something like JAXB or Castor. They both let you convert from a Java object -> XML and XML -> Java object.
Upvotes: 0
Reputation: 67892
Apparently JAXB can do marshalling/unmarshalling. I've not used it, but it seems to do what you want. From there, you can use an ORM of some type to put your objects in a database, or you can handcraft SQL.
Upvotes: 0
Reputation: 597402
Your question is rather obscure and general. There are a number of options for converting XML to Java objects:
This article could be useful.
But anyway you will have to read much before getting something more complex to work.
This is all in case you need to map your xml to java objects. If you just need to parse the XML:
Upvotes: 6
Reputation: 16941
Check this: http://www.java-tips.org/java-se-tips/javax.xml.parsers/how-to-read-xml-file-in-java.html That's how you read xml file. Then you just crate SQL query to insert it into database (JDBC?)
Upvotes: 1