<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];
}