Eslam Totti
Eslam Totti

Reputation: 125

Convert xml string to NSMutableArray

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

I Want to store text of every elemnt in NSMutableArray

Upvotes: 0

Views: 743

Answers (2)

Mathew Varghese
Mathew Varghese

Reputation: 4527

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

Upvotes: 0

Inder Kumar Rathore
Inder Kumar Rathore

Reputation: 39988

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];
}

Upvotes: 1

Related Questions