• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Populating a NSMenu with an heirachical NSXMLDocument
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Populating a NSMenu with an heirachical NSXMLDocument


  • Subject: Re: Populating a NSMenu with an heirachical NSXMLDocument
  • From: Matt Neuburg <email@hidden>
  • Date: Wed, 14 Jun 2006 17:42:27 -0700
  • Thread-topic: Populating a NSMenu with an heirachical NSXMLDocument

On Wed, 14 Jun 2006 21:30:28 +1000, "John Cassington"
<email@hidden> said:
>Hello,
>I have a NSXMLDocument created from the following XML
>
><xml>
>    <status>listing_ok</status>
>    <folder id=\"0\" name=\"MyBox\" shared=\"0\" shared_link=\"\">
>        <folders>
>            <folder id=\"1811981\" name=\"Documents\" shared=\"0\"
>shared_link=\"\">
>                <tags></tags>
>                <folders></folders>
>                <files></files>
>            </folder>
>            <folder id=\"1812046\" name=\"School\" shared=\"0\"
>shared_link=\"\">
>                <tags></tags>
>                <folders>
>                    <folder id=\"1876523\" name=\"Engineering\" shared=\"0\"
>shared_link=\"\">
>                        <tags></tags>
>                        <folders></folders>
>                        <files>
>                            <file id=\"11907763\" file_name=\"Engineering
>Workbook.doc\" >
>                                <tags>
>                                    <tag id=\"19754\" /><tag id=\"19755\"
>/><tag id=\"19756\" />
>                                </tags>
>                            </file>
>                        </files>
>                    </folder>
>                </folders>
>                <files>
>                    <file id=\"11907764\" file_name=\"Engineering
>Assignment.doc\">
>                    <tags></tags></file>
>                </files>
>            </folder>
>        </folders>
>        <files></files>
>    </folder>
>    <pages>1</pages>
></xml>
>
>... and i want to create a NSMenu with the <folder> items as submenus and
><file> as items of those submenus
>
>i have tried to do this using example code, but i do not have any idea on
>how to handle the heirarchy
>
>[aNode level] seemed to have some use, but i am at a loss

Well, it isn't hard. Basically you're going to cycle / recurse thru your
hierarchy. You're going to start with a menu and add menu items to it. If a
menu item needs a submenu, create that menu and add it to the menu item as
its submenu, and now you can add menu items to *that*. I find it easiest to
start by parsing the XML into a more congenial data structure (such as a
simple tree sort of thing) that directly reflects the structure of the menu
I'm going to build. m.

--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Apple Data Plotting Framework
  • Next by Date: Testing
  • Previous by thread: Populating a NSMenu with an heirachical NSXMLDocument
  • Next by thread: Canceling the insertion of a managed object
  • Index(es):
    • Date
    • Thread