加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

生成xml数据

发布时间:2020-12-16 09:19:27 所属栏目:百科 来源:网络整理
导读:message type="chat" to="zhq1@localhost" from="123@localhost"bodyhhhh/body/message / ** * 发送消息 */ - ( void )sendMessage:( NSString *)_msg to:( NSString *)_to { // 创建一个 xml NSXMLElement *message = [ NSXMLElement elementWithName : @"m

<message type="chat" to="zhq1@localhost" from="123@localhost"><body>hhhh</body></message>


/**

* 发送消息

*/

- (void)sendMessage:(NSString *)_msg to:(NSString *)_to

{

//创建一个xml

NSXMLElement *message = [NSXMLElement elementWithName:@"message"];

[message addAttributeWithName:@"type" stringValue:@"chat"];

[message addAttributeWithName:@"to" stringValue:[NSString stringWithFormat:@"%@@localhost",_to]];

[message addAttributeWithName:@"from" stringValue:[NSString stringWithFormat:@"123@localhost"]];

NSXMLElement *body = [NSXMLElement elementWithName:@"body"];

[body setStringValue:_msg];

[message addChild:body];

NSLog(@"%@",message);

[xmppStream sendElement:message];

}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读