Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-04-2010, 08:37 PM   #1 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 58
pufftissue is on a distinguished road
Default Parsing xml into a tree-like menu with submenus? Multiple delegates sample code?

Hi,

I have a question about parsing the following structure. As you can see, categories is a repeating nested element. But I can't figure out how to parse this with NSXML Parser.

Can someone help me figure out how to convert this xml into a drill-down table view that lists categories? So in other words:

TableView Level 1

cardiology

TableView Level 2
primary_hypertension
secondary_hypertension

TableView Level 3 (revealed if secondary_hypertension is selected)
congestive_heart_failure
no_congestive_heart_failure



Code:
<?xml version="1.0" encoding="UTF-8"?>
<root>cardiology
    <category>hypertension
        <child>
            <category>primary_hypertension 
            </category>
        </child>
        <child>
            <category>secondary_hypertension 
                <child>
                    <category>congestive_heart_failure</category>
                </child>
                <child>
                    <category>no_congestive_heart_failure</category>
                </child>
            </category>
        </child>
    </category>        
</root>
The issue seems to be the repeating nested categories. Sometimes one category has numerous subcategories. Other times a given category might have no subcategories. Is my xml constructed wrong? Thanks!

My problem is exactly the same as a guy who wanted to parse the following xml into menus and submenus. The multiple delegates sample is hard for me to follow as it is a snippet and not a full fleshed out example. Pointers and samples would be appreciate:

Code:
   1. <testxml>  
   2. <Menu>  
   3.     <MenuItem>  
   4.         <menuName>Menu 1</menuName>  
   5.         <MenuChildren>  
   6.             <MenuItem>  
   7.                 <menuName>Sub-Menu 1</menuName>  
   8.             </MenuItem>  
   9.             <MenuItem>  
  10.                 <menuName>Sub-Menu 1a</menuName>  
  11.                 <MenuChildren>  
  12.                     <MenuItem>  
  13.                         <menuName>Sub-Sub-Menu 1aa</menuName>  
  14.                     </MenuItem>  
  15.                 </MenuChildren>  
  16.             </MenuItem>  
  17.         </MenuChildren>  
  18.     </MenuItem>  
  19.     <MenuItem>  
  20.         <menuName>Menu 2</menuName>  
  21.     </MenuItem>  
  22.     <MenuItem>  
  23.         <menuName>Menu 3</menuName>  
  24.     </MenuItem>  
  25.     <MenuItem>  
  26.         <menuName>Menu 4</menuName>  
  27.     </MenuItem>  
  28. </Menu>  
  29. </testxml>

Last edited by pufftissue; 08-04-2010 at 11:40 PM.
pufftissue is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 324
10 members and 314 guests
alexP, arash5500, gordo26, mediaspree, nobstudio, Objective Zero, rayjeong, Sloshmonster, stanny, Touchmint
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:23 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0