To create a node containing encoded CDATA text, use the initWithKind: options: method in NSXMLNode.
NSXMLNode *cdataNode = [[NSXMLNode alloc] initWithKind:NSXMLTextKind options:NSXMLNodeIsCDATA];
[cdataNode setStringValue:@"<some text>"];
And to write the XML data to a file :
NSData *xmlData = [xmlDoc XMLDataWithOptions:NSXMLNodePrettyPrint];
[xmlData writeToFile:fileName atomically:YES];
source
share