Re: How to add a DOCTYPE declaration to an NSXMLDocument?
Re: How to add a DOCTYPE declaration to an NSXMLDocument?
- Subject: Re: How to add a DOCTYPE declaration to an NSXMLDocument?
- From: Bruce Sharpe <email@hidden>
- Date: Wed, 31 Mar 2010 00:36:06 -0700
> Doing either of these would have led you to the setName: method, which I suspect is what you're after here.
Sounds promising, but the document type declaration doesn't get
written out to file. I create the document like this:
NSXMLDocument *myDoc = [[NSXMLDocument alloc]
initWithRootElement:[NSXMLElement elementWithName:@"myDocType"]];
NSXMLDTD *myDTD = [[NSXMLNode alloc] initWithKind:NSXMLDTDKind];
[myDTD setName:@"myDocType"];
[myDoc setDTD:theDTD];
and write it like this (after adding several elements to it):
NSData *myData = [myDoc XMLDataWithOptions:NSXMLNodePrettyPrint];
[myData writeToFile:aPath atomically:YES];
Other XML documents, ones I don't create but get from somewhere else,
show the doctype declaration when I run them through the same write
routine.
To add further to the confusion, if I do this, I do see the doctype
declaration in the output:
NSLog(@"%@", myDoc);
Any suggestions would be appreciated.
Bruce
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden