I want to parse the XML data using NSXMLParser. In my root node is location and i want to extract the values for street, city, state and postal_code. I could take the name attribute values and how can i take the inner values of address node.
Here the xml node is,
<location id="10001">
<name>Pugal Devan</name>
<address>
<street>112, Jawahar Street </street>
<city>Kolkata</city>
<state>West Bengal</state>
<postal_code>10002</postal_code>
</address>
</location>
Thanks!
asked Apr 7, 2011 at 15:10
Pugalmuni
9,3908 gold badges60 silver badges98 bronze badges
1 Answer 1
You could create a class that looks like:
@interface Location {
NSString* name;
NSString* street;
NSString* city;
NSString* state;
NSString* postalCode;
}
Then just use the normal methods to parse the XML while creating Location objects to hold the parsed data. Here is a very thorough example on how to parse the data.
answered Apr 7, 2011 at 15:19
FreeAsInBeer
13k5 gold badges54 silver badges84 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
default