Here is what I use to create an XHTML post (thanks to Thomas Perl /Jabberbot.py)
html_message = "<b>Test!</b>"
plain_message = re.sub(r'<[^>]+>', '', html_message)
message = xmpp.protocol.Message(body=plain_message)
html = xmpp.Node('html', {'xmlns': 'http://jabber.org/protocol/xhtml-im'})
html.addChild(node=xmpp.simplexml.XML2Node("<body xmlns='http://www.w3.org/1999/xhtml'>" + html_message.encode('utf-8') + "</body>"))
message.addChild(node=html)
source
share