Solved

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

Posted on 2007-11-15
5
259 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Configure a Bean in an XML file 4 49
How do I remove an object from a 3 53
java example issue 5 46
Tomcat 9 + java 8 error while trying to deploy a war file 2 727
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

726 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