NSXMLParser and duplicate tags
I have a xml file. That I want to parse with NXXMLParser. I have a开发者_JAVA技巧 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 tokenIDHow can I extract the data and assign it to their respective array.
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.
精彩评论