The following code produces the equivalent XML :

NSXMLDocument *myDoc = [[NSXMLDocument alloc] initWithRootElement:[NSXMLElement 
elementWithName:@"myDocType"]];
NSXMLDTD *myDTD = [[NSXMLNode alloc] initWithKind:NSXMLDTDKind];
[myDTD setName:@"myDocType"];
[myDoc setDTD:myDTD];
[myDoc setVersion:@"1.0"];
[myDoc setCharacterEncoding:@"UTF-8"];
        
[[myDoc XMLData] writeToFile:[@"~/Desktop/TestXML.xml" 
stringByExpandingTildeInPath] atomically:YES];

  - Steve


On 31 Mar 2010, at 09:31, [email protected] wrote:

>> Sounds promising, but the document type declaration doesn't get written
> out to file.
> 
> If I create the document using a string instead, it works:
> 
> NSString *docString = [NSString stringWithFormat:@"<!DOCTYPE
> myDocType><myDocType></myDocType>"];
> NSXMLDocument *myDoc = [[NSXMLDocument alloc] initWithXMLString:docString
> options:0 error:&err];
> [[myDoc DTD] setName:@"myDocType"];
> 
> Seems equivalent to half a dozen other things I tried, but this is the only
> one that works.
> 
> Bruce

_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to