Bindings make this really easy.
You can use a NSTreeController combined with an NSOutlineView and very little code if you use standard bindings.
To make the NSXML objects in the sample application work together with the NSTreeController object, you simply have to add a couple methods to the NSXMLNode class through a category.
https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/NSXML_Concepts/Articles/UsingTreeControllers.html
#import "NSXMLNode+NSXMLNodeAdditions.h"
@implementation NSXMLNode (NSXMLNodeAdditions)
- (NSString *)displayName {
NSString *displayName = [self name];
if (!displayName) {
displayName = [self stringValue];
}
return displayName;
}
- (BOOL)isLeaf {
return [self kind] == NSXMLTextKind ? YES : NO;
}
@end
here are screenshots of the relevant settings for both the NSTreeContoller

and NSOutlineView's TableColumn
