2012-09-04 21:29:11 +00:00
|
|
|
#import "ObjectTesting.h"
|
|
|
|
#import <Foundation/NSAutoreleasePool.h>
|
|
|
|
#import <Foundation/NSXMLDocument.h>
|
|
|
|
#import <Foundation/NSXMLElement.h>
|
2018-01-14 12:30:13 +00:00
|
|
|
#import "GNUstepBase/GSConfig.h"
|
2012-09-04 21:29:11 +00:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
2018-01-14 12:30:13 +00:00
|
|
|
START_SET("NSXMLDocument CDATA")
|
|
|
|
#if !GS_USE_LIBXML
|
|
|
|
SKIP("library built without libxml2")
|
|
|
|
#else
|
2012-09-04 21:29:11 +00:00
|
|
|
NSString *docString = @"<root><node><![CDATA[How to read this text ?]]></node></root>";
|
|
|
|
NSData *data = [docString dataUsingEncoding: NSUTF8StringEncoding];
|
|
|
|
NSError *outError = nil;
|
|
|
|
NSXMLDocument *document = [[[NSXMLDocument alloc]
|
|
|
|
initWithData: data
|
|
|
|
options: (NSXMLNodePreserveCDATA | NSXMLNodePreserveWhitespace)
|
|
|
|
error: &outError] autorelease];
|
|
|
|
NSXMLElement *rootElement = [document rootElement];
|
|
|
|
NSXMLNode *childNode = [rootElement childAtIndex: 0];
|
|
|
|
NSString *cData = [childNode stringValue];
|
|
|
|
PASS_EQUAL(cData, @"How to read this text ?", "CDATA element is correct");
|
2018-01-14 12:30:13 +00:00
|
|
|
#endif
|
2012-09-04 21:29:11 +00:00
|
|
|
|
2018-01-14 12:30:13 +00:00
|
|
|
END_SET("NSXMLDocument CDATA")
|
2012-09-04 21:29:11 +00:00
|
|
|
[arp release];
|
|
|
|
arp = nil;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|