<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6001.18099" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=123024122-02102008><FONT face=Arial
color=#0000ff size=2>You're asking about how to read the data efficiently with
JDOM, but I suspect that if you are looking for performance then you might be
looking in the wrong part of your system.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=123024122-02102008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=123024122-02102008><FONT face=Arial
color=#0000ff size=2>XML parser start-up costs can be very high; initializing
the parser for each document could easily turn out to be the dominant cost in
this application. You can get a lot of saving by reusing parser instances. I
don't know what JDOM's initialization costs for building a document are, but you
need to check them too.</FONT></SPAN></DIV>
<DIV><SPAN class=123024122-02102008><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=123024122-02102008><FONT face=Arial color=#0000ff size=2>At any
rate, building a JDOM tree almost certainly takes longer than extracting the
data from the tree once built.</FONT></SPAN></DIV>
<DIV><SPAN class=123024122-02102008><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=123024122-02102008><FONT face=Arial color=#0000ff size=2>I find
this statement a bit worrying:</FONT></SPAN></DIV>
<DIV><SPAN class=123024122-02102008><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=123024122-02102008>>Anyway, since there is probably not much
I can do with the network latency, I am trying to keep the Java code as skinny
and efficient as possible.<BR></SPAN></DIV>
<DIV><SPAN class=123024122-02102008><FONT face=Arial color=#0000ff size=2>That
seems to be an inversion of the way performance engineering should be done. If
network latency is the dominant cost, then effort spent on tuning your Java code
is a total waste of time.</FONT></SPAN></DIV>
<DIV><SPAN class=123024122-02102008><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=123024122-02102008><FONT face=Arial color=#0000ff size=2>I
would focus your attention on measuring performance, end to end, before you
start tuning anything.</FONT></SPAN></DIV>
<DIV><SPAN class=123024122-02102008><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=123024122-02102008><FONT face=Arial color=#0000ff
size=2>Michael Kay</FONT></SPAN></DIV>
<DIV><SPAN class=123024122-02102008><FONT face=Arial color=#0000ff size=2><A
href="http://www.saxonica.com/">http://www.saxonica.com/</A></FONT></DIV></SPAN>
<DIV dir=ltr align=left><BR></DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> jdom-interest-bounces@jdom.org
[mailto:jdom-interest-bounces@jdom.org] <B>On Behalf Of </B>Praveen
Gattu<BR><B>Sent:</B> 02 October 2008 23:04<BR><B>To:</B> Paul
Libbrecht<BR><B>Cc:</B> jdom-interest@jdom.org<BR><B>Subject:</B> Re:
[jdom-interest] Re: Reading XML with JDOM<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV dir=ltr>Paul,<BR><BR>Thanks for the response. My XML is really as simple
as the one I posted. The 8,500 documents are retrieved over a HTTP URL. So add
network latency, which makes it longer than a minute, unless my XML parser is
extremely fast. Anyway, since there is probably not much I can do with the
network latency, I am trying to keep the Java code as skinny and efficient as
possible.<BR><BR>Would you be able to provide sample code for the solution you
suggested?<BR><BR>
<DIV class=gmail_quote>On Thu, Oct 2, 2008 at 2:27 PM, Paul Libbrecht <SPAN
dir=ltr><<A
href="mailto:paul@activemath.org">paul@activemath.org</A>></SPAN>
wrote:<BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">Praveen,<BR><BR>in
jdom you would just parse then take the root, then the employee, the extract
last-name and ssn.<BR>It is ignoring from the point of view of your
programme but not from the point of view of parsing.<BR><BR>Where you can
save is by changing the xml technology... if your document is as simple as
below then using sax has greater performance guarantees (you really cannot
go faster) but is harder to programme with.<BR>Another part where jdom can
take too much of your CPU is if this document has loads of other
stuffs.<BR><BR>Where JDOM would make a positive difference is at walking
more elaborate xml documents, which is the norm, and at manipulating them.
The expressivity of the library there is unbeatable to my
taste.<BR><BR>However, your requirements sound easy: 8500 such documents per
minutes?<BR>JDOM does this probably ten times, multithreadedness not being
really necessary.<BR><BR>paul
<DIV>
<DIV></DIV>
<DIV class=Wj3C7c><BR><BR>On 02-oct.-08, at 20:29, Praveen Gattu
wrote:<BR><BR></DIV></DIV>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<DIV>
<DIV></DIV>
<DIV class=Wj3C7c>I have a XML as below. There is always "only one"
employee node in the XML. So rather than iterating through the nodes, I
want to read the lastname and ssn directly, while ignoring the firstname.
What is the best way to do this in JDOM? My most important criteria is
speed. We will be processing about a 8,500 of such XML documents per
minute (multi-threaded of course) and need something efficient and
fast. I appreciate any help you can offer in this
regard.<BR><BR><response><BR> <employee><BR>
<firstname>John</firstname><BR>
<lastname>Smith</lastname><BR>
<ssn>111-11-1111</ssn><BR> </employee><BR></response><BR><BR>--
<BR>Thanks,<BR>Praveen<BR><BR><BR><BR><BR>--
<BR>Thanks,<BR>Praveen<BR></DIV></DIV>_______________________________________________<BR>To
control your jdom-interest membership:<BR><A
href="http://www.jdom.org/mailman/options/jdom-interest/"
target=_blank>http://www.jdom.org/mailman/options/jdom-interest/</A><A
href="mailto:youraddr@yourhost.com"
target=_blank>youraddr@yourhost.com</A><BR></BLOCKQUOTE><BR></BLOCKQUOTE></DIV><BR><BR
clear=all><BR></DIV></BLOCKQUOTE></BODY></HTML>