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: Sat, 18 Nov 2006 18:03:17 +0000
Thanks for the response.
Your suggestion does preserve the white space but I'm left with the
problem of losing the xml structure in the string.
To set the value of the NSXMLElement I would use:
[element setStringValue:xmlString];
Ideally I'm looking for something like:
[element setXMLStringValue:xmlString];
But I've not found any such method in the documentation. Is there an
alternative?
On 18 Nov 2006, at 16:28, Nir Soffer wrote:
On Nov 18, 2006, at 17:41, Al Skipp wrote:
I'm trying to create a simple XML document which holds information
regarding text styling, so it is important to maintain white space
between words, but I'm having difficulty achieving this. Here's an
example.
I'd like to form this string into an XML element:
NSString *xmlString =@"<paragraph>The <bold>cat</bold>
<italic>sat</italic> on the <bold>mat</bold></paragraph>";
if I try this:
NSXMLElement *xml = [[[NSXMLElement alloc]
initWithXMLString:xmlString error:&err]autorelease];
then I lose the spacing between 'cat' and 'sat'.
I can use:
NSXMLDocument *xml = [[[NSXMLDocument alloc]
initWithXMLString:xmlString options:NSXMLNodePreserveWhitespace
error:&err]autorelease];
which preserves spacing, though I don't want a new NSXMLDocument,
I need a new element to add to an existing document.
Is there a way of creating an NSXMLElement with
'options:NSXMLNodePreserveWhitespace'?
I've attempted using:
NSXMLElement *xml = [[[NSXMLElement alloc]
initWithKind:NSXMLElementKind options:NSXMLNodePreserveAll]
autorelease];
and then setting the name and string. However, the XML in the
string is then escaped as thus: <bold>cat</bold>
How about
NSXMLElement *element = [[[NSXMLElement alloc]
initWithKind:NSXMLElementKind
options:NSXMLNodePreserveWhitespace] autorelease];
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