On Sat, 27 Mar 2010 16:59:35 -0700, Bruce Sharpe <bruce.sha...@gmail.com> said: >I want to add a DOCTYPE declaration to my NSXMLDocument, but can't seem to >find the right incantation. The thing that comes closest to working is: > >NSString *myXMLString = [NSString stringWithFormat:@"<?xml version=\"1.0\" >encoding=\"UTF-8\"?><myDocElement></myDocElement>"]; >NSXMLDocument *myDoc = [[NSXMLDocument alloc] initWithXMLString:myXMLString >options:0 error:&err]; >NSString *myDoctypeString = @"<!DOCTYPE myDocElem>"; >NSXMLDTD *theDTD = [[NSXMLDTD alloc] initWithData:[myDoctypeString >dataUsingEncoding:NSUTF8StringEncoding] options:nil error:&err]; >[myDoc setDTD:theDTD]; > >The result should be: > ><?xml version="1.0" encoding="UTF-8"?> ><!DOCTYPE myDocElement> ><myDocElement></myDocElement> > >but what I get is: > ><?xml version="1.0" encoding="UTF-8"?> ><!DOCTYPE > ><myDocElement></myDocElement> > >What am I doing wrong?
I can think of two things you might be doing wrong: (1) You might be failing to consult the documentation for NSXMLNode. (2) You might be failing to check the archives. Doing either of these would have led you to the setName: method, which I suspect is what you're after here. m. -- matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/> A fool + a tool + an autorelease pool = cool! AppleScript: the Definitive Guide - Second Edition! http://www.tidbits.com/matt/default.html#applescriptthings _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com