0

I have XML data parched in a NSMutableArray and i need to loop through the array to see all values stored in it. This may be a stupid question but this is all new to me.

The xml file looks like this

<list>
<item id="1">
<title>Title 1</title>
<title>Content 1</title>
</item>
<item id="2">
<title>Title 2</title>
<title>Content 2</title>
</item>
</list>

This is the array that all data is collected

NSMutableArray *articleList=[[ArticleService getArticleList] retain];

If i output NSLog(@"articleList: %@", articleList); on this is the result I get, so I guess there is some data inside of the array.

2011-06-14 21:51:04.690 NAF[954:207] articleList: (
"<Article: 0x8021170>",
"<Article: 0x80214a0>",
"<Article: 0x8020660>",
"<Article: 0x802ba30>",
"<Article: 0x802a520>",
"<Article: 0x80267a0>",
"<Article: 0x8025bd0>",
"<Article: 0x80141e0>",
"<Article: 0x8024390>",
"<Article: 0x8026bb0>",
"<Article: 0x8029630>",
"<Article: 0x8019390>",
"<Article: 0x8015b50>",
"<Article: 0x8014dd0>",
"<Article: 0x8012fb0>"
)

So to the question. How can I loop true the array and get the value of every 'title' of the XML file. Im a hell of a cut and paste programmer, so if someone can be so helpful providing me with some code, I will appriciate it a lot.

1
  • Well, without knowing the data structure used for each article instance there's no way one can tell you how to do what you want. Commented Jun 14, 2011 at 19:58

1 Answer 1

3

Assuming that each article has a property called title

for(Article* a in articleList)
{
    NSLog(@"Title = %@",a.title);
{
Sign up to request clarification or add additional context in comments.

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.