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>
아무도 나에게 다음과 같은 종류의 XML 표현을 제공하는 NSXMLElement를 만들 수 있도록 도와주세요. 그것이 완료되지
NSXMLElement *iq = [NSXMLElement elementWithName:@"iq"];
[iq addAttributeWithName:@"type" stringValue:@"set"];
[iq addAttributeWithName:@"id" stringValue:@"pip1"];
[iq addChild:[NSXMLElement elementWithName:@"pubsub" xmlns:@"http://jabber.org/protocol/pubsub"]];
NSXMLElement *publish = [NSXMLElement elementWithName:@"publish"];
[publish addAttributeWithName:@"node" stringValue:@"storage:bookmarks"];
NSXMLElement *item = [NSXMLElement elementWithName:@"item"];
[item addAttributeWithName:@"id" stringValue:@"current"];
[publish addChild:item];
[publish addChild:[NSXMLElement elementWithName:@"storage" xmlns:@"storage:bookmarks"]];
NSXMLElement *conference = [NSXMLElement elementWithName:@"conference"];
[iq addChild:publish];
--
--
--;
,하지만 난 당신이 그것을 수행하는 방법 아이디어를 얻었기를 바랍니다 :
<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