Hello!!!
I have a use case scenario where I need output to be simultaneously a well-formed HTML fragment AND a well-formed XML fragment. This is what Wikipedia calls a polyglot.
I found the following excerpt from your documentation:
Beautiful Soup’s handling of empty-element XML tags has been improved. Previously when you parsed XML you had to explicitly say which tags were considered empty-element tags. The selfClosingTags argument to the constructor is no longer recognized. Instead, Beautiful Soup considers any empty tag to be an empty-element tag. If you add a child to an empty-element tag, it stops being an empty-element tag.
Actually, in the case of a well-formed polyglot, the passing of a list or function would have been better. Please make it clear that if you need an empty non-self-closing tag, you should add the empty string as a child.
tag.clear()
tag.append("")