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

I Want to store text of every elemnt in NSMutableArray

2
  • have you tried anything.. there are allot of tutorial here.. just parse it and you will get you result.. Commented Jul 6, 2012 at 14:48
  • please see my answer and follow the same link.. Commented Jul 6, 2012 at 15:05

2 Answers 2

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];
}
Sign up to request clarification or add additional context in comments.

1 Comment

I would suggest the XML parser rather than transforming the xml string. But either way will work in this case.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.