Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

read in a xml file

 
Michael.H.Sun
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
I would like to have a Java servlet that reads an XML file, determines the format of the data, creates a table in SQL Server 7.0 to accept the file and loads the file into the SQL Server table.
Please tell me if this is feasible. If so, would give me some basic instructions on coding it?
Greatly appreciate your help.
Michael
 
Chris Stehno
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it is feasable.
Use an XML parser (I recomment Xerces www.apache.org) to parse your xml file. I prefer using SAX parsers over DOM, but that is mostly a personal preference. Put some data type cues in your xml so that you can quickly determine the data format (such as a data type tag or something).
Use your content handler or read your DOM tree to create your SQL table.
Java and XML is a really good book on the subject from Oreilly.
Good luck.
 
Michael.H.Sun
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chris,
Thank you for the instructions. I will try what you said. If I have more questions, I may paste them again.
Michael
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use Jdom is a lot easier. www.jdom.org
 
Michael.H.Sun
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Roseanne. I will try JCOM.
Michael
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic