3 * Copyright (c) 2002 - 2007, Blue Static <http://www.bluestatic.org>
5 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
6 * General Public License as published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
10 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along with this program; if not,
14 * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 #import <Cocoa/Cocoa.h>
19 @implementation NSXMLElement (NSXMLElementAdditions
)
22 * Return's the property's name from the attributes list
24 - (NSString
*)variable
26 return [[self attributeForName
: @
"name"] stringValue
];
30 * Returns whether or not this node has any children
34 BOOL leaf
= ([[[self attributeForName
: @
"children"] stringValue
] intValue
] == 0);
36 // hmm... we're not a leaf but have no children. this must be beyond our depth, so go make us
38 if (!leaf
&& [[self children
] count
] < 1)
40 // count upwards to see how deep we should go
42 NSXMLElement
*elm
= self;
46 elm
= (NSXMLElement
*)[elm parent
];
48 NSLog(@
"let's go to depth %d for %@", depth
, self);
55 * Returns the value of the property
59 return [self stringValue
];
63 * Returns the type of variable this is
67 return [[self attributeForName
: @
"type"] stringValue
];