NSXMLELEMENT simple question

78 views
Skip to first unread message

obaid

unread,
Jul 3, 2012, 6:47:24 AM7/3/12
to xmppfr...@googlegroups.com
Actually I want to pass the xml stanza that is <iq type='invisible />

however for different xml stanza like <iq from='som...@gmail.com" to="som...@yahoo.com> child elements </iq>

so to pass this i use this

    NSXMLElement *iq=[NSXMLElement elementWithName:@"iq"];
    [iq addAttributeWithName:@"from" stringValue:@"som...@gmail.com"];
    [iq addAttributeWithName:@"to" stringValue:@"som...@yahoo.com"];

    [self.xmppStream sendElement:presenceaway];

so the matter of face it gives the output with two tags <iq> </iq> and the elements between it or inside it.

But now I want just one tag and addAttribute in it <iq type='invisible' /> and it should end in the same tag. How to to this?

I know I'm missing something important, can anybody help me out?





obaid

unread,
Jul 3, 2012, 7:59:20 AM7/3/12
to xmppfr...@googlegroups.com
As per the (XMPPIQ *)iqWithType:(NSString *)type; is sent it in this way

nsxmlelement *iq=[xmppiq iqwithtype:@"invisible"];

[self.xmppstream sendelement:iq];

nslog(@"output is %@",iq);

So now also I get the same output respone as <iq type='invisible'> </iq>

But I would need the output as <iq type='invisible" /> if you notice it closely the "/" the iq tag is closed in the same tag, how to do that?

On Tuesday, July 3, 2012 1:47:24 PM UTC+3, obaid wrote:
Actually I want to pass the xml stanza that is <iq type='invisible />

however for different xml stanza like <iq from='som...@gmail.com" to="som...@yahoo.com> child elements </iq>

so to pass this i use this

    NSXMLElement *iq=[NSXMLElement elementWithName:@"iq"];
    [iq addAttributeWithName:@"from" stringValue:@"someone@gmail.com"];
    [iq addAttributeWithName:@"to" stringValue:@"someone@yahoo.com"];

Robbie Hanson

unread,
Jul 3, 2012, 8:21:40 PM7/3/12
to xmppfr...@googlegroups.com
So now also I get the same output respone as <iq type='invisible'> </iq>

But I would need the output as <iq type='invisible" /> if you notice it closely the "/" the iq tag is closed in the same tag, how to do that?

[iq XMLString] = @"<iq type='invisible'></iq>"
[iq compactXMLString] = @"<iq type='invisible'/>"

There is also a prettyXMLString method.

This is primarily applicable to logging. When you send elements via [xmppStream sendElement], it automatically uses compactXMLString to save bandwidth.

-Robbie Hanson


--
You received this message because you are subscribed to the Google Groups "XMPPFramework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/xmppframework/-/-CE-pAtRHrEJ.
To post to this group, send email to xmppfr...@googlegroups.com.
To unsubscribe from this group, send email to xmppframewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/xmppframework?hl=en.

Obaid Shaik

unread,
Jul 4, 2012, 1:38:36 AM7/4/12
to xmppfr...@googlegroups.com
Thank you! for the solution :).
Reply all
Reply to author
Forward
0 new messages