开发者

Sending XHTML over Jabber using xmpppy

开发者 https://www.devze.com 2023-01-08 04:58 出处:网络
I\'m trying to send XHTML (a hyperlink) over Jabber (to Google Talk) using xmpppy, but can\'t find a good working example... I tried with this:

I'm trying to send XHTML (a hyperlink) over Jabber (to Google Talk) using xmpppy, but can't find a good working example... I tried with this:

http://intertwingly.net/blog/2007/08/09/Se开发者_运维问答nding-XHTML-over-Jabber

But didn't work... any ideas??

Thanks in advance!

M


Heres a nugget I use to construct a XHTML message (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)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号