0
我收到以下XML IQ並希望在iOS中解析它。請幫忙!xmpp iOS中的IQ XML解析
<iq type="result">
<stories xmlns="success">
<storyid>1</storyid>
<title>THE TITLE</title>
<picture>BASE64EncodedStringOfImage</picture>
<storyid>2</storyid>
<title>Love At First Site</title>
<picture>BASE64EncodedStringOfImage</picture>
</stories>
</iq>
我試過下面的代碼,但它不工作。它獲得successStoryArray
中的值,但之後沒有任何值。請幫忙!
NSXMLElement *stories = [iq elementForName:@"stories"];
NSArray *successStoryArray = [stories elementsForName:@"storyid"];
NSLog(@"successStoryArray: %@", successStoryArray);
for (NSXMLElement *i in successStoryArray)
{
NSXMLElement *title = [i elementForName:@"title"];
NSString *sTitle = [title stringValue];
NSLog(@"sTitle: %@", sTitle);
NSXMLElement *picture = [i elementForName:@"picture"];
NSString *sPicture = [picture stringValue];
NSLog(@"sPicture: %@", sPicture);
}
什麼具有u試過?嘗試一下,如果你根本不知道從哪裏開始http://techglimpses.blogspot.in/2013/03/xml-parsing-in-ios-sample-code.html –
@代理我已經添加了以上我所嘗試過的。 –