开发者

Sending special characters in XMPP

开发者 https://www.devze.com 2023-04-06 08:29 出处:网络
So I\'m trying to send a string like this <message to=\"me\"><body>\\<foobar\\></body></message>

So I'm trying to send a string like this

<message to="me"><body>\<foobar\></body></message>

The brackets seem to stop the transmission of the message, is t开发者_如何学Chere any way to escape the characters for example? How can I do this?


You need to properly escape the content for XML. In your case, the message must end up like this:

<message to="me"><body>\&lt;foobar\&gt;</body></message>

For an entity escaper, have a look into StringEscapeUtils (I assume that you're doing this in Java).


As XMPP is an XML application, I'd try replacing < with &lt;, & with &amp; and, probably not necessarily, > with &gt;.

0

精彩评论

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