Objective C XML parser

From , 5 Years ago, written in Objective-C, viewed 80 times.
URL https://pastebin.vip/view/df438e52
  1. // Define the XML Document
  2. NSXMLDocument* doc = [[NSXMLDocument alloc] initWithXMLString:[NSString stringWithContentsOfFile:@"/folder/with/sample.xml"]];
  3.  
  4. // Create the arrays here
  5. NSMutableArray* objects = [[NSMutableArray alloc] initWithCapacity:10];
  6. NSMutableArray* descriptions = [[NSMutableArray alloc] initWithCapacity:10];
  7.  
  8. NSXMLDocument* doc = [[NSXMLDocument alloc] init...];
  9. NSXMLElement* root  = [doc rootElement];
  10. NSArray* objectElements = [root nodesForXPath:@"//object" error:nil];
  11. for(NSXMLElement* xmlElement in objectElements)
  12.     [objects addObject:[xmlElement stringValue]];
  13.  
  14. NSArray* descElements = [root nodesForXPath:@"//description" error:nil];
  15. for(NSXMLElement* xmlElement in descElements)
  16.     [descriptions addObject:[xmlElement stringValue]];
  17.  
  18. [doc release];
  19. [objects release];
  20. [descriptions release];
  21. //objectc/4010

Reply to "Objective C XML parser"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website