开发者

writing CDATA block to NSXMLDocument file

开发者 https://www.devze.com 2022-12-22 17:54 出处:网络
How can one write CDATA block in开发者_运维知识库 XML file and save it to a file in cocoa. To create a node containing CDATA encoded text, use method initWithKind:options: on NSXMLNode.

How can one write CDATA block in开发者_运维知识库 XML file and save it to a file in cocoa.


To create a node containing CDATA encoded text, use method initWithKind:options: on NSXMLNode.

NSXMLNode *cdataNode = [[NSXMLNode alloc] initWithKind:NSXMLTextKind  options:NSXMLNodeIsCDATA];
[cdataNode setStringValue:@"<some text>"];

And to write xml data to a file:

NSData *xmlData = [xmlDoc XMLDataWithOptions:NSXMLNodePrettyPrint];
[xmlData writeToFile:fileName atomically:YES];
0

精彩评论

暂无评论...
验证码 换一张
取 消