Remove multiple nodes from an xml file using sax and java

pspgms

New Member
I am new to XML parsing using Java and SAX parser. I have a really big XML file and because of its size I have been advised to use SAX parser. I have finished parsing part of my tasks and it works as expected. Now, there is one task left with XML job: deleting/updating some nodes upon user's request.I am able to find all tags by their names, change their \[code\]data\[/code\] attributes, etc. If I am able to do these with SAX, deleting also may be possible.Sample XML describes some functionality under some case's. User's inputs are the "case"s names (\[code\]case1\[/code\], \[code\]case2\[/code\]).\[code\]<ruleset> <rule id="1"> <condition> <case1>somefunctionality</case1> <allow>true</allow> </condition> </rule> <rule id="2"> <condition> <case2>somefunctionality</case2> <allow>false</allow> </condition> </rule></ruleset>\[/code\]If user wants to delete one of these cases (for example \[code\]case1\[/code\]) not just \[code\]case1\[/code\] tag, the complete \[code\]rule\[/code\] tag must be deleted. If \[code\]case1\[/code\] is to be deleted, XML will become:\[code\]<ruleset> <rule id="2"> <condition> <case2>somefunctionality</case2> <allow>false</allow> </condition> </rule></ruleset>\[/code\]My question is, can this be done using SAX? I can't use DOM or any other parser at this point. Only other option is even worse: string search. How can it be done using SaxParser?
 
Back
Top