I am searching in the whole internet on how can I store my xml data to a NSDictionary, but it seems that I can't find a solution that will fix my problem. I need to store my data into a NSDictionary, the data comes from xml stored in a url. Is there a algorithm on how to do it? Without using any 3rd party program if possible
Asked
Active
Viewed 269 times
0
-
Possible duplicate of [Parse XML to NSDictionary](http://stackoverflow.com/questions/26553557/parse-xml-to-nsdictionary) – Jean-Baptiste Yunès Jun 14 '16 at 05:50
1 Answers
0
Use NSXMLParser
:
NSURL *yoururl = [NSURL URLWithString:[NSString stringWithFormat:@"http://Enter your URL here"]];
NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:yoururl];
parser.delegate = self;
[parser parse];
-(void)parser:(NSXMLParser*)parser didStartElement:(NSString*)elementName namespaceURI:(NSString*)namespaceURI
qualifiedName:(NSString*)qualifiedName attributes:(NSDictionary*)attributeDict
{
//Use attributeDict to get parsed XML into NSDictionary
}
And for more info see this:
I hope this will help you..:)

Community
- 1
- 1

Suraj Sukale
- 1,778
- 1
- 12
- 19
-
Is it normal to have \t and \n in the text of my xml? I am able to parse it and here's a sample text = "\n\t\t\n\t\t\tCheck"; – drbj Jun 14 '16 at 07:24
-
see this bro : https://www.raywenderlich.com/553/xml-tutorial-for-ios-how-to-choose-the-best-xml-parser-for-your-iphone-project OR.. https://github.com/71squared/TBXML – Suraj Sukale Jun 14 '16 at 07:39