This inserts a new element and child at the very bottom of the doc within the "main" root:
NSXMLElement *root = [[xmlDoc rootElement] initWithName:@"main"];
NSXMLElement *firstElement = [[NSXMLElement alloc] initWithName:@"first"];
[root addChild:firstElement];
NSXMLElement *secondElement = [NSXMLNode elementWithName:@"second"];
[firstElement addChild:secondElement];
I need this to be inserted up top of the doc as the first or second node.. How can I do this?
Thanks.
-paul.
EDIT:
Ugh ... I can't believe it was this easy ...
[root insertChild:firstElement atIndex:1];
This solved it:
[root insertChild:firstElement atIndex:1];