title: Example of SAX XML Parser for iPhone in iOS
body: <p>Can somebody post a link of SAX XML parser example in XCode, not from developer.apple.com.
  I need to parse this XML file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;userfood_overview xmlns="http://www.wikifood.lu"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.wikifood.lu userfood.xsd"&gt;
  &lt;hits&gt;1&lt;/hits&gt;
  &lt;startAt&gt;0&lt;/startAt&gt;
  &lt;userfood&gt;
  &lt;id&gt;770&lt;/id&gt;
  &lt;ean&gt;4016249502058 &lt;/ean&gt;
  &lt;name&gt;&lt;![CDATA[Amaranth-Früchte-Müsli / Großpackung]]&gt;&lt;/name&gt;
  &lt;modification&gt;2012-10-09&lt;/modification&gt;
  &lt;info1&gt;&lt;![CDATA[Amaranth - Müsli mit Früchten]]&gt;&lt;/info1&gt;
  &lt;origin id="55"&gt;Germany&lt;/origin&gt;
  &lt;brand&gt;
  &lt;id&gt;155&lt;/id&gt;
  &lt;name&gt;&lt;![CDATA[Allos]]&gt;&lt;/name&gt;
  &lt;/brand&gt;
  &lt;contents&gt;&lt;![CDATA[1,5]]&gt;&lt;/contents&gt;
  &lt;unit id="8"&gt;Kilogram&lt;/unit&gt;
  &lt;nutrition_facts&gt;
  &lt;nutrition_fact id="Per_100_g_ml"&gt;
  &lt;name&gt;per 100&lt;/name&gt;
  &lt;value&gt;g&lt;/value&gt;
  &lt;unit/&gt;
  &lt;/nutrition_fact&gt;
  &lt;nutrition_fact id="EnergyKcal"&gt;
  &lt;name&gt;Energy kcal&lt;/name&gt;
  &lt;value&gt;377&lt;/value&gt;
  &lt;unit&gt;kcal&lt;/unit&gt;
  &lt;/nutrition_fact&gt;
  &lt;nutrition_fact id="EnergyKjoule"&gt;
  &lt;name&gt;Energy kj&lt;/name&gt;
  &lt;value&gt;1580&lt;/value&gt;
  &lt;unit&gt;kj&lt;/unit&gt;
  &lt;/nutrition_fact&gt;
  &lt;/nutrition_facts&gt;
  &lt;allergens&gt;
  &lt;allergen id="774"&gt;&lt;![CDATA[Nuts]]&gt;&lt;/allergen&gt;
  &lt;allergen id="773"&gt;&lt;![CDATA[Milk (including lactose)]]&gt;&lt;/allergen&gt;
  &lt;allergen id="777"&gt;&lt;![CDATA[Sesame seeds]]&gt;&lt;/allergen&gt;
  &lt;allergen id="782"&gt;&lt;![CDATA[Gluten]]&gt;&lt;/allergen&gt;
  &lt;allergen id="772"&gt;&lt;![CDATA[Soy]]&gt;&lt;/allergen&gt;
  &lt;/allergens&gt;
  &lt;food_notes/&gt;
  &lt;category id="0602003" delimiter=":"&gt;&lt;![CDATA[Muesli]]&gt;&lt;/category&gt;
  &lt;insertion&gt;2007-01-16&lt;/insertion&gt;
  &lt;editable&gt;false&lt;/editable&gt;
  &lt;/userfood&gt;
  &lt;/userfood_overview&gt;
  </code></pre>
  
  <p>, but from documentation on <a href="http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/XMLParsing/Articles/UsingParser.html#//apple_ref/doc/uid/20002264-BCIIJEEH" rel="nofollow">http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/XMLParsing/Articles/UsingParser.html#//apple_ref/doc/uid/20002264-BCIIJEEH</a> it's not clear for me.
  This is what I have:</p>
  
  <pre><code>#pragma mark *** NSXMLParserDelegate ***
  
  - (void)parserDidStartDocument:(NSXMLParser *)parser
  {
      // do preparation for loading data from XML
  }
  
  - (void)parserDidEndDocument:(NSXMLParser *)parser
  {
      [parser release];
  }
  
  - (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError
  {
      //analyze parseError
      [parser release];
  }
  
  - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict
  {
      NSLog(@"elementName %@", elementName); // current parsing element
      // specify type of data to be saved in method below
  }
  
  - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
  {
      NSLog(@"value of element %@", string); // value for current parsing element
      // save data to some ivar for future use (displaying)
  }
  </code></pre>
  
  <p>Thanks.</p>