0
我正在開發聊天應用程序,並且需要創建具有所需xml結構的nsxmlobject。爲xml響應創建nsxmlobject iOS,
ios代碼我用於簡單的XML。
NSString* server = @"conference.server.local"; //or whatever the server address for muc is
XMPPJID *servrJID = [XMPPJID jidWithString:server];
XMPPIQ *iq = [XMPPIQ iqWithType:@"get" to:servrJID];
[iq addAttributeWithName:@"from" stringValue:[xmppStream myJID].full];
NSXMLElement *query = [NSXMLElement elementWithName:@"query"];
[query addAttributeWithName:@"xmlns" stringValue:@"http://jabber.org/protocol/disco#items"];
[iq addChild:query];
[xmppStream sendElement:iq];
上述代碼用於創建以下xml格式。
<iq from='[email protected]/pda'
id='yh2fs843'
to='[email protected]/laptop'
type='get'>
<query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
任何人都可以請幫助我創建NSXMLElement,它給了我以下類型的XML表示。
<iq from='[email protected]/balcony' type='set' id='pip1'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<publish node='storage:bookmarks'>
<item id='current'>
<storage xmlns='storage:bookmarks'>
<conference name='The Play's the Thing'
autojoin='true'
jid='[email protected]'>
<nick>JC</nick>
</conference>
</storage>
</item>
</publish>
<publish-options>
<x xmlns='jabber:x:data' type='submit'>
<field var='FORM_TYPE' type='hidden'>
<value>http://jabber.org/protocol/pubsub#publish-options</value>
</field>
<field var='pubsub#persist_items'>
<value>true</value>
</field>
<field var='pubsub#access_model'>
<value>whitelist</value>
</field>
</x>
</publish-options>
</pubsub>
</iq>
謝謝Bhumeshwer,會試試看。非常感謝你 – Satish
嘿Bhumeshwer,你能幫我解決這個問題:http://stackoverflow.com/questions/20793311/xmpp-ios-framework-trying-to-write-it-in-objective-c – DevCali