[Objective-C] objective C xml解析器 →→→→→进入此内容的聊天室

来自 , 2019-03-05, 写在 Objective-C, 查看 131 次.
URL http://www.code666.cn/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

回复 "objective C xml解析器"

这儿你可以回复上面这条便签

captcha