Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Remove Element from XML

 
Monty Guppy
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic