• 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: Cocoa-dev Digest, Vol 6, Issue 794
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa-dev Digest, Vol 6, Issue 794


  • Subject: Re: Cocoa-dev Digest, Vol 6, Issue 794
  • From: "McLaughlin, Michael P." <email@hidden>
  • Date: Thu, 28 May 2009 08:45:22 -0400
  • Acceptlanguage: en-US
  • Thread-topic: Cocoa-dev Digest, Vol 6, Issue 794

On 5/27/09 6:42 PM, "Greg Guerin <email@hidden> wrote:

>> In reviewing the NSXML documents, I found no really simple way to
>> traverse a
>> subtree of an NSXMLDocument.  That is, traverse from the root until
>> you hit
>> the node with the right name then pretend that that node is the
>> root of a
>> smaller tree and traverse just the latter.  [Everything I found
>> talked only
>> about sibs and (immediate) children, not grandchildren, etc.]
>>
>> Since this is such a common thing to do, I'm guessing that I must have
>> misread the docs somehow.
>>
>> Could someone clue me in as to the preferred method to do a
>> subtraversal?
>
> Recursion:
>   http://en.wikipedia.org/wiki/Recursion
>
> Given any NSXMLNode, if it has children, you can traverse the
> children.  Since each child is itself an NSXMLNode, the "Given any
> NSXMLNode..." sentence at the begining of this paragraph applies.
> The previous two sentences are recursive.
>
> Start recursion at the root node of the NSXMLDocument.

I'm familiar with recursion; that is what prompted my query.  However, the
tree-traversal documentation at

http://devworld.apple.com/documentation/Cocoa/Conceptual/NSXML_Concepts/Arti
cles/TraversingTree.html#//apple_ref/doc/uid/TP40001257

seems to indicate that the built-in traversal method, nextNode, is
non-recursive (in the usual sense).  This method will return non-nil until
the whole tree is finished.  I was looking for some indicator that I had
finished just a subtree.  [Perhaps level will work.]

--
Mike McLaughlin

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Cocoa-dev Digest, Vol 6, Issue 794
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: Laying out superscripted text
  • Next by Date: Re: How determine if file is in Trash, given Path or Alias
  • Previous by thread: How to make our application as default for particular type of file.
  • Next by thread: Re: Cocoa-dev Digest, Vol 6, Issue 794
  • Index(es):
    • Date
    • Thread