Hi

I am looking some advice on which Java tools to use and /or any hints you can offer a new Java user regarding XML.

What I want to do is take an xml file read it, modify it and push it to a database so that it can update multiple tables and maintain its relationships. I will be repeating this often.

There are so many libraries to do this, well as it appears, however most of the tutorials demonstrate simple activities like retrieving 2 elements from an overly simple XML file.

I can do the steps separately, parse a basic xml file, create and update and query databases but I cannot figure out how to do it or find a practical tutorial that demonstrates how to do it.

If you had any info re tools, tutorial/reading, workflow etc I would really appreciate your advice.

There is do little info on net regarding this would really appreciate any advice.

Look into a library called JAXB. It basically eases the task of XML <-> Java objects conversion. The steps would look something like this:

  1. Analyze the XML file format and create a XSD out of it (this is the difficult part)
  2. Autogenerate classes from XSD using xjc
  3. Load XML file and create objects of out it using the JAXB API
  4. Use JDBC to insert those objects in the database

One tutorial which highlights the steps above is this. Once you have the objects, inserting them into the DB shouldn't be that difficult.

Thanks so much for this. Will sit down tonight and give it a go.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.