XML Parsing Question

Discussion in 'iOS Apps' started by thabart, Mar 22, 2011.

  1. thabart macrumors newbie

    Joined:
    Mar 22, 2011
    #1
    Dear all,

    I always considered myself to be an OK programmer when it came to HTML, PHP and C/C++ but the iOS SDK and Xcode is really frustrating me. It feels like a complete different world.

    I'm trying to realize a freeware program that displays my college's cafeteria daily menu. For this purpose they provided me with a XML interface, with a rather complicated structure.

    Now I'm following this tutorial (click) to implement a basic XML parser. So far so good. In this example every element only appears once per node (i.e. no more than one date per blog entry). The XML I'm working with, however, looks something like this:

    Code:
     <group type="1" location="106" productiondate="2011-03-22" sort="8">
        <name>Meal name</name>
        <internalname>Meal A</internalname>
        <prices size="3">
          <price consumerID="0">2.7</price> //prices depend on status (i.e. student, staff, faculty) 
          <price consumerID="1">4.2</price>
          <price consumerID="2">6.0</price>
        </prices>
        <taggings size="3">
          <tagging taggingID="51">Pork</tagging> //details like meat type and additives
          <tagging taggingID="1">Color-Additives</tagging>
          <tagging taggingID="2">Preservatives</tagging>
        </taggings>
        <components size="3">
          <component elementid="127048" sort="1"> 
            <name1>Meal Description</name1>
          </component>
          <component elementid="127049" sort="2">
            <name1>Side dish 1</name1>
          </component>
          <component elementid="127050" sort="3">
            <name1>Side dish 2</name1>
          </component>
        </components>
      </group>
    How can I combine all name1 elements per group node in one array? Also I don't quite understand how this line works:

    Code:
    int storyIndex = [indexPath indexAtPosition:[indexPath length] - 1];
    	[cell setText:[[stories objectAtIndex: storyIndex] objectForKey: @"title"]]; 
    	return cell;
    How can I include all name1, one price and all tagging elements in one row displayed in a UITable? Also I'd like to create a new UITable per group node on the same page. What is the best way to go about this?

    Any help is highly appreciated and if you could adjust the sample code to process my XML I'd love you forever ;)
     
  2. thabart thread starter macrumors newbie

    Joined:
    Mar 22, 2011

Share This Page