I am new to XML parsing using Java and SAX parser. I have a really large XML file, and because of its size, I was advised to use a SAX parser. I have finished analyzing my tasks, and it works as expected. Now there remains one task with the task of XML: removing / updating some nodes at the request of the user.
I can find all tags by their names, change their data attributes, etc. If I can do this using SAX, deletion may also be possible.
The XML example describes some functions in some cases. User inputs are case names ( case1 , case2 ).
<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>
If the user wants to delete one of these cases (for example, case1 ), not only the case1 tag, the full rule tag must be deleted. If case1 needs to be removed, the XML will be as follows:
<ruleset> <rule id="2"> <condition> <case2>somefunctionality</case2> <allow>false</allow> </condition> </rule> </ruleset>
My question is: can this be done using SAX? At the moment, I cannot use the DOM or any other parser. Even worse is another option: search for strings. How can this be done with SaxParser?
source share