• 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: NSXML - preserving white space in new elements
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >NSXML - preserving white space in new elements (From: Al Skipp <email@hidden>)
 >Re: NSXML - preserving white space in new elements (From: Pascal Pochet <email@hidden>)
 >Re: NSXML - preserving white space in new elements (From: Nir Soffer <email@hidden>)
 >Re: NSXML - preserving white space in new elements (From: Al Skipp <email@hidden>)
 >Re: NSXML - preserving white space in new elements (From: Nir Soffer <email@hidden>)

  • Prev by Date: window shadow and setAlphaValue bug?
  • Next by Date: Overriding bind:toObject:withKeyPath:options:
  • Previous by thread: Re: NSXML - preserving white space in new elements
  • Next by thread: Importing CICN resources from file
  • Index(es):
    • Date
    • Thread