How do you send HTML formatted messages over XMPP with Node.JS?

浪尽此生 提交于 2020-01-14 04:27:08

问题


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:


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.



来源:https://stackoverflow.com/questions/6509206/how-do-you-send-html-formatted-messages-over-xmpp-with-node-js

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!