3

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/Sending-XHTML-over-Jabber

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

Thanks in advance!

M

Neurus
  • 657
  • 4
  • 27
  • What exactly is "didn't work"? What happened when you tried it? – rbp Jul 22 '10 at 16:03
  • message=Message('a_user@gmail.com','hi there') payload=xmpp.simplexml.XML2Node('%s' % (xml.dom.XML_NAMESPACE, '%s: %s' % ('http://google.com', 'hi there', 'abc'))) message.addChild('html', {}, [payload], xmpp.NS_XHTML_IM) when sending the message, it sends a plain "hi there" (no link) – Neurus Jul 22 '10 at 16:21

1 Answers1

2

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)
Andrew Williams
  • 227
  • 2
  • 9