views:

35

answers:

3

hello everyone.In my application am getting an xml file from server and in that i have some attributes for the element.i donno how to read the attributes can anyone help me please..

A: 

NSXMLParser is a SAX-parser that is part of the iOS SDK. There are plenty of tutorials available if your google-fu is strong.

Event-Driven XML Programming Guide

willcodejavaforfood
A: 

In the NSXMLParser class, you read the attributes for an element in the following event supplied by the class:

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict;

The last argument attributes:(NSDictionary *)attributeDict gives you a dictionary of the attribute-value pairs if there are any.

Philip Regan
A: 

You can start from the following tutorial

http://theappleblog.com/2008/08/04/tutorial-build-a-simple-rss-reader-for-iphone/

And after that read a very good document provided by Apple to map to your requirements.

Introduction to Event-Driven XML Programming Guide for Cocoa provided by Apple.

itsaboutcode
am not understanding the links provided by you please could you xplin it clearly.my xml file is <History><Result ImageId="4507" Description="" Date="10/19/2010 12:49:22 AM" /><Result ImageId="4505" Description="" Date="10/18/2010 8:01:28 AM" /></History> o i want to assign ImageId,Description and Date into three variables and i want to save each result into an array. Reading data from that
iphoneStruggler
If you are getting problem in undersanding that tutorial, look at the following on. http://dblog.com.au/general/iphone-sdk-tutorial-building-an-advanced-rss-reader-using-touchxml-part-1/
itsaboutcode