0
NSString *xml=@"<string>aaaa</string><string>bbbb</string><string>ccccc</string>";

I Want to store text of every elemnt in NSMutableArray

Eslam Totti
  • 125
  • 2
  • 13

2 Answers2

1

Either you use xml parser which is the best option.
I suggest you TBXML and its performance is better than others

or

Try this. mtbArray is you all require

NSString *xml=@"<string>aaaa</string><string>bbbb</string><string>ccccc</string>";
xml = [xml stringByReplacingOccurrencesOfString:@"</string>" withString:@""];
NSArray *array = [xml componentsSeparatedByString:@"<string>"];
NSMutableArray *mtbArray = [array mutableCopy];
if ([mtbArray count]) {
    [mtbArray removeObjectAtIndex:0];
}
Inder Kumar Rathore
  • 39,458
  • 17
  • 135
  • 184
  • I would suggest the XML parser rather than transforming the xml string. But either way will work in this case. – Gil Sand May 04 '15 at 08:18
0

You can better use the NSXMLParser for the purpose. Hope this helps you.

Mathew Varghese
  • 4,527
  • 2
  • 17
  • 26