Posted By

arpit on 06/11/10


Tagged

xml iphone DDXML


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

espinallab
umang_nine


Using DDXML to parse an XML file


 / Published in: Objective C
 

  1. NSString *filePath = [[NSBundle mainBundle] pathForResource:@"data" ofType:@"xml"];
  2. NSData *data = [NSData dataWithContentsOfFile:filePath];
  3. if (data) {
  4. NSError *error = nil;
  5. DDXMLDocument* doc = [[DDXMLDocument alloc]initWithData:data options:0 error:&error];
  6.  
  7. if(error != nil){
  8. NSLog(@"DDXMLDocument create failed! Error - %@", [error localizedDescription]);
  9. return;
  10. }
  11. NSArray* results = [listingsXMLDoc nodesForXPath:@"//node" error:&error];
  12. NSLog(@"parsed: %i", [results count]);
  13. }

Report this snippet  

You need to login to post a comment.