Re: NSXML - preserving white space in new elements
Re: NSXML - preserving white space in new elements
- Subject: Re: NSXML - preserving white space in new elements
- From: Al Skipp <email@hidden>
- Date: Sun, 19 Nov 2006 22:51:29 +0000
Your suggestions have been incredibly helpful. I'll try and implement
the category as you mentioned.
Thanks very much,
Al
On 19 Nov 2006, at 20:04, Nir Soffer wrote:
Detach just detach the node from it parent. You can use:
NSXMLElement *element = [fragment rootElement];
[element detach];
[textFrame addChild:element];
I would add a category with a method to create element from xml
string:
@interface NSXMLElement (CreatingFromXML)
+ (NSXMLElement *)elementWithXMLString:(NSString *)xmlString
options:(unsigned int)mask error:(NSError **)error;
@end
@implementation NSXMLElement (CreatingFromXML)
+ (NSXMLElement *)elementWithXMLString:(NSString *)xmlString
options:(unsigned int)mask error:(NSError **)error
{
NSXMLDocument *fragment = [[[NSXMLDocument alloc]
initWithXMLString:xmlString
options:options error:error];
if (fragment == nil)
return nil;
NSXMLElement *result = [fragment rootElement];
[result detach];
[fragment release];
return result;
}
@end
Warnings: written in Mail, untested
Best Regards,
Nir Soffer
_______________________________________________
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