How do you send HTML formatted messages over XMPP

2019-06-03 16:24发布

This question discusses sending messages with node-xmpp: Connecting to Google Talk over XMPP on Node.js

Anyone know how to get an HTML formatted message. The library they are using escapes the HTML in a node module called ltx.

1条回答
【Aperson】
2楼-- · 2019-06-03 17:01

See XEP-0071. Make sure your HTML is valid XML (XHTML), then embed like this:

<message>
  <body>Wow, I&apos;m green with envy!</body>
  <html xmlns='http://jabber.org/protocol/xhtml-im'>
    <body xmlns='http://www.w3.org/1999/xhtml'>
      <p style='font-size:large'>
        <em>Wow</em>, I&apos;m <span style='color:green'>green</span>
        with <strong>envy</strong>!
      </p>
    </body>
  </html>
</message>

Note that the plain text is also included for clients that can't render XHTML.

查看更多
登录 后发表回答