You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by ch...@tcs.com on 2004/08/27 06:48:33 UTC

Reading entire tree structure of an XML

Hi,


My XML has atleast 5 levels of nested elements. How can i read the entire 
data and put
it in a Container so that i can use that data for processing ?


Thanks and Regards,

Chetan 

Re: SV: Reading entire tree structure of an XML

Posted by Phil Weighill-Smith <ph...@volantis.com>.
As Martin indicated, the choice of DOM vs SAX is commonly because of the
overall expected data set size rather than the number of levels of
nesting.

If you've got an XML application that contains just a "few" complex
entries then DOM is probably reasonable. If however you expect a lot of
complex entries and are worried about performance issues (because of
memory issues) then use SAX.

Again, as Martin suggests, you can use SAX to build fragments of your
data set (e.g. so you process a single complex entry at a time). By
writing your SAX ContentHandler to actually generate the required DOM
nodes you can even "fool" the rest of your application into thinking it
is working with normal DOMs that happen to only contain a single complex
entry at a time (for example).

Phil :n)

On Fri, 2004-08-27 at 08:25, chetan.arora@tcs.com wrote:

> Hi Martin,
> 
> Actually i have nested elements which sometimes go upto 4 levels of
> nesting. Is it still advisable to go in for SAX or
> is it definitely DOM in this case ?
> 
> 
> Thanks,
> 
> Chetan Arora
> 
> 
> 
> Martin Gülich
> <ma...@foi.se>
> 
> 08/27/2004 12:43 PM
>          Please respond to
>    xerces-j-user@xml.apache.org
>                To
> <xe...@xml.apache.org>
>                cc
> 
>           Subject
> SV: Reading
> entire tree
> structure of an
> XML
> 
> 
> 
> 
> Hi!
> Use DOM parsing! But if you have a large file it might be inefficient,
> then SAX parsing is better. If you only want to handle ONE entire
> element at a time you can build your own tree structure for that
> element only by using a stack or something similar. Then discard the
> tree and build a new for the next element etc.
>  
> Martin Gülich
> Research Engineer
> ______________________________
> 
> Swedish Defence Research Agency
> Dept. Of Systems Modelling
> SE-172 90 Stockholm, Sweden
> 
> Phone: +46 8 55503691
> Company web site: www.foi.se
>  
> -----Ursprungligt meddelande-----
> Från: chetan.arora@tcs.com [mailto:chetan.arora@tcs.com] 
> Skickat: den 27 augusti 2004 06:49
> Till: xerces-j-user@xml.apache.org
> Ämne: Reading entire tree structure of an XML
>  
> 
> Hi,
> 
> 
> My XML has atleast 5 levels of nested elements. How can i read the
> entire data and put
> it in a Container so that i can use that data for processing ?
> 
> 
> Thanks and Regards,
> 
> Chetan 
> ForwardSourceID:NT00002892    
> 
> 
> ______________________________________________________________________
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org

-- 
Phil Weighill-Smith <ph...@volantis.com>
Volantis Systems

Re: SV: Reading entire tree structure of an XML

Posted by ch...@tcs.com.
Hi Martin,

Actually i have nested elements which sometimes go upto 4 levels of 
nesting. Is it still advisable to go in for SAX or
is it definitely DOM in this case ?


Thanks,

Chetan Arora




Martin Gülich <ma...@foi.se> 
08/27/2004 12:43 PM

Please respond to
xerces-j-user@xml.apache.org


To
<xe...@xml.apache.org>
cc

Subject
SV: Reading entire tree structure of an XML






Hi!
Use DOM parsing! But if you have a large file it might be inefficient, 
then SAX parsing is better. If you only want to handle ONE entire element 
at a time you can build your own tree structure for that element only by 
using a stack or something similar. Then discard the tree and build a new 
for the next element etc.
 
Martin Gülich
Research Engineer
______________________________

Swedish Defence Research Agency
Dept. Of Systems Modelling
SE-172 90 Stockholm, Sweden

Phone: +46 8 55503691
Company web site: www.foi.se
 
-----Ursprungligt meddelande-----
Från: chetan.arora@tcs.com [mailto:chetan.arora@tcs.com] 
Skickat: den 27 augusti 2004 06:49
Till: xerces-j-user@xml.apache.org
Ämne: Reading entire tree structure of an XML
 

Hi, 


My XML has atleast 5 levels of nested elements. How can i read the entire 
data and put 
it in a Container so that i can use that data for processing ? 


Thanks and Regards, 

Chetan 
ForwardSourceID:NT00002892 

SV: Reading entire tree structure of an XML

Posted by Martin Gülich <ma...@foi.se>.
Hi!

Use DOM parsing! But if you have a large file it might be inefficient, then
SAX parsing is better. If you only want to handle ONE entire element at a
time you can build your own tree structure for that element only by using a
stack or something similar. Then discard the tree and build a new for the
next element etc.

 

Martin Gülich
Research Engineer
______________________________

Swedish Defence Research Agency
Dept. Of Systems Modelling
SE-172 90 Stockholm, Sweden

Phone: +46 8 55503691
Company web site: www.foi.se <http://www.foi.se/> 

 

-----Ursprungligt meddelande-----
Från: chetan.arora@tcs.com [mailto:chetan.arora@tcs.com] 
Skickat: den 27 augusti 2004 06:49
Till: xerces-j-user@xml.apache.org
Ämne: Reading entire tree structure of an XML

 


Hi, 


My XML has atleast 5 levels of nested elements. How can i read the entire
data and put 
it in a Container so that i can use that data for processing ? 


Thanks and Regards, 

Chetan