All I want to do is parse the XML below and delete Peter and Sam element as they dont have any children (also can say empty) and President element after that as it will be empty.
This nested thing is driving me crazy!
<Office id="xyz" scope="node">
<John>
<age>23</age>
<ssn>230231111</ssn>
</John>
<Peter>
</Peter>
<John>
<age>25</age>
<ssn>222222222</ssn>
</John>
<President>
<Sam>
</Sam>
</President>
</Office>
It looks like you want:
whitespace)
Do it 2x to remove President too.