File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes Remove Element from XML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Remove Element from XML" Watch "Remove Element from XML" New topic
Author

Remove Element from XML

Monty Guppy
Ranch Hand

Joined: Sep 15, 2001
Posts: 49
I am using SAX parser to parse XML that is returned as a CLOB from an Oracle SP. The XML could be like this:
<RECORDSET>
<RECORD>
<NAME>Dave</NAME>
<ID>123</ID>
</RECORD>
<RECORD>
<NAME>Ken</NAME>
<ID>124</ID>
</RECORD>
.......
</RECORDSET>
Based on some logic, I determine that the element called <NAME> needs to be be removed completely from all <RECORD>s before this potentaillay huge XML file (there could be 1000's of records and scored os elements within each record) is processed further.
Is there a recommended way to accomplish this? Should I rather convert SAX to DOM, then remove element, then convert back to SAX? Please advise.
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
Use JDOM SAXBuilder will solve your problem. JDOM uses SAX to parse your XML but only load the parts you access into memory (Lazy-initialization pattern).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Remove Element from XML
 
Similar Threads
[XSL] XML to XML without empty element
Using Hibernate to Read XML
Jasper Reports Cookbook- userdefined XML to PDF possible
how to construct attribute list
SAX parser issue,character call back method being called twice