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: Matt Neuburg <email@hidden>
- Date: Tue, 30 Mar 2010 11:09:02 -0700
- Thread-topic: How to add a DOCTYPE declaration to an NSXMLDocument?
On Sat, 27 Mar 2010 16:59:35 -0700, Bruce Sharpe <email@hidden>
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 = email@hidden, <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 (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