I just want to parse a String received from a Post Response, I know there are lib/classes like NSXMLParse and apple provides some example but not what I want, or I'm not ready to understand that code.
I receive this:
<object>
<id>1</id>
<alias>juan</alias>
<email>[email protected]</email>
</object>
<object>
<id>2</id>
<alias>juana</alias>
<email>[email protected]</email>
</object>
Then I need to parse, and get the data like this:
NSString *xmlThing = [response];
for xmlThing in-all <object>
{
uint id = <id>1</id>
NSString *alias = <alias>juan</alias>
NSString *email = <email>[email protected]</email>
}
Why like this? because I think is the easiest way to do and parse all kind of html, xml, etc... files.
I appreciate all kind of help.
NSXMLParserlooks like it would be the right choice for your example. What part about it are you having a hard time with?https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSXMLParser_Class/Reference/Reference.htmlwhich method I should use to know how many <object></object> are in the xml file? I need to know to loop all of them, then how I tell to return the value from a <id></id> label?NSXMLParseruses a pattern called delegation. See this SO post about delegation. It is used extensively through out all of the iOS/Foundation/UIKit APIs. The answer below is straight forward and should answer your question directly.