File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes XML Processing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "XML Processing" Watch "XML Processing" New topic

XML Processing

Matt Corban

Joined: Apr 05, 2012
Posts: 2
I am currently working on a project where I need to process different xml files. Each element in the xml file has its own column name. I need to either store the entire xml in the database or process each element in the xml file and store it as a database object. If I store it as an object, I will need to process certain elements as dates and manipulate strings in order to store them in the database. If I store the xml directly to the database, I will need to later translate each element to a column name when I display it as html. So far, I am able to store the xml as a database object. The problem is each xml file has similar or different columns and I am having to create additional methods in order to store it as a database object. I am trying to avoid creating additional methods in order to process the columns. Any ideas on better ways to do this?
Pat Farrell

Joined: Aug 11, 2007
Posts: 4659

You really have no choice, at some point you have to parse the XML to get access to the fields that contain the dates, strings, etc.

There are lots of XML parsing libraries, I recommend you find one you like and use it.

If you know that the XML is simple, and will never change, and will never get complex, you can try to write your own parser, but since there are well documented, tested, free libraries that you can use, its rarely worthwhile to write your own.
Matt Corban

Joined: Apr 05, 2012
Posts: 2
Thanks Pat. That helps.
I agree. Here's the link:
subject: XML Processing
It's not a secret anymore!