生成xml数据
<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]; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |