It is possible to remove parent node and previous parent node if the matched node is empty?
Example:
<div>
<div>
<p>Banana
</p>
</div>
<table>
<tbody>Not empty</tbody>
<tr>
<td>A</td>
</tr>
</table>
<div>
<p>Apple
</p>
</div>
<table>
<tbody></tbody>
</table>
</div>
If <table>-><tbody> is empty I would like to remove <table> and previous <div> node.
Example output:
<div>
<div>
<p>Banana
</p>
</div>
<table>
<tbody>Not empty</tbody>
<tr>
<td>A</td>
</tr>
</table>
</div>
divelements followed by atableelement that contains an emptytbodyelement and (b) suchtableelements themselves.