Solved

Best XML parser for Java - just want to get specific fields

Posted on 2007-11-15
5
258 Views
Last Modified: 2013-12-29
I have a decent sized XML input file, a few thousand lines, that contains and invoice with between 1 and n number of item loops, as well as some overall order info.  I need to parse that data in a java servlet and insert the data in to a sql database.  That is an over-simplification of the process, in reality some data may be missing and I need to get it elsewhere (another DB), or data may be in different places depending on the vendor (invoice may not have item loops and instead have total information and some items in comments).

My question is what is the best XML parser to use in Java to accomplish this (considering I'm a beginner).  I think I need one that will load the whole document because I may need to randomly access elements all over the document.  Is this something that should involve xquery or xpath, and maybe saxon?
0
Comment
Question by:arrkerr1024
5 Comments
 
LVL 17

Expert Comment

by:contactkarthi
ID: 20298163
I will advice you to use xpath

http://www.cafeconleche.org/books/xmljava/chapters/ch16.html

use the below tool if you are going to use xpath to get help in generating the query
http://weblogs.asp.net/nleghari/articles/27951.aspx

have a look at this tutorial for sax vs dom

http://developerlife.com/tutorials/?p=28

also have a look at
http://www.xml.com/pub/rg/SAX_vs_DOM

0
 
LVL 6

Expert Comment

by:VBGuru
ID: 20468117
if you are thinking of making your coding life easier? then you can think of using JAXB
0
 
LVL 14

Accepted Solution

by:
arrkerr1024 earned 0 total points
ID: 20707697
the best solution turned out to be to strip down the original xml using xsl and the saxon parser, then to use grab it with java.
0
 
LVL 1

Expert Comment

by:Vee_Mod
ID: 20747291
Closed, 500 points refunded.
Vee_Mod
Community Support Moderator
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now