I need to eliminate xml node based on these three rules.First scenario:\[code\]<root> <sector> <nodeA id="a"> <section id="i"> <!-- this is an example where it occurs in one parent --> <item1 id="1" method="create"> <somechild>a</somechild> </item1> <item1 id="1" method="delete" /> </section> </nodeA> <nodeA id="b"> <cell id="ii"> <item1 id="2" method="create"> <somechild>a</somechild> </item1> </cell> <cell id="ii"> <item1 id="2" method="delete" /> </cell> </nodeA> </sector> </root>\[/code\]Output:\[code\]<root> <sector> <nodeA id="a"> <section id="i"> </section> </nodeA> <nodeA id="b"> <cell id="ii"> > </cell> <cell id="ii"> </cell> </nodeA> </sector> </root>\[/code\]Second scenario:\[code\]<root> <sector> <nodeA id="a"> <section id="ii"> <!-- this is an example where it occurs in different parent that has the same id --> <item1 id="0" method="delete"/> </section> <section id="ii"> <item1 id="0" method="create"> <somechild>a</somechild> </item1> </section> </nodeA> </sector> </root>\[/code\]Output:\[code\]<root> <sector> <nodeA id="a"> <section id="ii"> </section> <section id="ii"> </section> </nodeA> </sector> </root>\[/code\]Third Scenario:\[code\]<root> <sector> <nodeB id="a"> <section id="i"> <item1 id="0" method="create"> <!-- this is an example where it occurs in different parent that has the same id --> <somechild>a</somechild> </item1> <item1 id="0" method="modify"> <otherchild>a</otherchild> </item1> </section> <section id="i"> <item1 id="0" method="delete"/> </section> </nodeB> </sector> </root>\[/code\]Output:\[code\]<root> <sector> <nodeB id="a"> <section id="i"> </section> <section id="i"> </section> </nodeB> </sector> </root>\[/code\]In conclusion we need to eliminate node according to these rules:
- one node with method create followed with one delete will be eliminated
- one node with method delete followed with one create will be eliminated
- one node with method create followed with one modify, followed with one delete will be eliminated