In my application, I have a tag multiple times. I’m using xml parser. I’m taking a corresponding element with similar name as the one in xml file in my class. So in case of:
<photo>abc</photo>
<photo>def</photo>
What I get in photo element of my class is the second element i.e def, as the first one gets overwritten as there’s only one photo element in my class. My question is am I wrong in taking similar elements in class as in case of xml? Is there any better method or a better parser? Or I’m on right path and have to do this manually by setting some flags etc?
Thanx in advance.
I assume you try to parse the contents of an XML to match to properties on an object using NSXMLParser.
If it is valid to encounter multiple
phototags in your XML then either you need a strategy to know which one will map to a property, or convert your property to anNSArrayand add the results as they come.If it is not a valid case, you could check if you set the property earlier and raise an error, or just override it (as you do) and call it “undefined behavior”.