I dont think you can save memory by deleting child nodes as it will cause an exception 
if you delete a child (implying it has a parent). Also, I dont see how it can save 
memory even if you could delete the child nodes because the DOM document is going to 
load the entire xml into memory atleast when you first load it. It is sad that you 
cannot use SAX as it was meant to solve this exact problem.

I will be interested in knowing if there is any solution the way you want it. But you 
can use some platform specific features to avoid memory problems. For example, if you 
are using Win32, try using the Memory Mapped files.

hth.
-Vinayak

> -----Original Message-----
> From: Lihong Pei [mailto:[EMAIL PROTECTED]
> Sent: Friday, March 07, 2003 5:27 PM
> To: [EMAIL PROTECTED]
> Subject: Questions on reading large xml file using DOM parser
> 
> 
> Hi,
> I'm trying to parse a large xml file (7MB) using DOM parser ( 
> I have to
> use DOM parser). The xml file is like the following:
> <root>
> <child1> ---------------------------<child1/>
> <child2> ---------------------------<child2/>
>                          .
>                          .
>                          .
> <childn> ---------------------------<childn/>
> <root/>
> After the parser read through child1, it does not need it anymore. The
> same case as child2 and ... and childn. I know this is a 
> perfect case for
> a SAX parser. However, I can't use it. I have to use DOM 
> parser. Is there
> any way to remove child1 once the parser finished reading it 
> so that the
> memory held by the parser is not too big?
> 
> There might be some similar question asked before. However, I 
> can't find
> it from the archive. Could you help with some hints?
> 
> Thanks a lot!
> 
> Lihong
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to