views:

30

answers:

1

I have a xml file. That I want to parse with NXXMLParser. I have a basic understanding of how to use NSXMLParser but ive reached this problem were the xml file is using duplicate tags for different reasons.

The xml file looks a little like this.

<member>
     <name>billy</name>
     <id>1</id>
</member>
<token>
     <name>login token</name>
     <id>1</id>
</token>

<member>
     <name>bob</name>
     <id>2</id>
</member>
<token>
     <name>login token</name>
     <id>2</id>
</token>

Now lets say I created created 4 arrays.
memberName
memberID
tokenName
tokenID

How can I extract the data and assign it to their respective array.

A: 

Just have a state variable as a member of the delegate - when you see a "member" tag start set the state to "member", when you see a "token" tag, set the state to "token".

Then when you see the "name" and "id" tag, check the state and add it to the right array.

JosephH
Amazing idea thanks.
Forgoten Dynasty