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 10:39:07 -0700
On Wed, Mar 31, 2010 at 7:14 AM, Steven Spencer <email@hidden> wrote:
>
> The following code produces the equivalent XML :
>
> NSXMLDocument *myDoc = [[NSXMLDocument alloc]
> initWithRootElement:[NSXMLElement elementWithName:@"myDocType"]];
> NSXMLDTD *myDTD = [[NSXMLDTD 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];
>
Thanks, Steve. That's much cleaner than my code and works well. (For
posterity, I changed NSXMLNode to NSXMLDTD in the above so it would be even
more beautiful. :)
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