I want to remove all the empty elements in the below string. If parent element is containing only empty child elements, then we need to remove the parent elements as well.
Actually, I am providing the replace function in perl below. But, I need it in python.
Perl:
while($text =~ s/<[^\/><]+>\s*<\/[^\/><]+>//si){}
**Here is my Input string:**
text = <transaction>
<trans>content</trans>
<dir></dir>
<curr>
<currency></currency>
<amount></amount>
</curr>
</transaction>
**Here is my Output string:**
text = <transaction>
<trans>content</trans>
</transaction>