开发者

How to parse the xml data using NSXML Parser in iPhone?

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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜