Posted By

saturngod on 02/17/11


Tagged


Versions (?)

XML to NSDictionary


 / Published in: Objective C
 

  1. //need https://github.com/bcaccinolo/XML-to-NSDictionary
  2.  
  3. NSString *testXMLString = @"<items><item id=\"0001\" type=\"donut\"><name>Cake</name><ppu>0.55</ppu><batters><batter id=\"1001\">Regular</batter><batter id=\"1002\">Chocolate</batter><batter id=\"1003\">Blueberry</batter></batters><topping id=\"5001\">None</topping><topping id=\"5002\">Glazed</topping><topping id=\"5005\">Sugar</topping></item></items>";
  4. // Parse the XML into a dictionary
  5. NSError *parseError = nil;
  6. NSDictionary *xmlDictionary = [XMLReader dictionaryForXMLString:testXMLString error:&parseError];
  7. // Print the dictionary
  8. NSLog(@"%@", xmlDictionary);

Report this snippet  

You need to login to post a comment.