• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to add a DOCTYPE declaration to an NSXMLDocument?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to add a DOCTYPE declaration to an NSXMLDocument?


  • Subject: Re: How to add a DOCTYPE declaration to an NSXMLDocument?
  • From: Steven Spencer <email@hidden>
  • Date: Wed, 31 Mar 2010 15:14:01 +0100

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@hidden 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@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

  • Follow-Ups:
    • Re: How to add a DOCTYPE declaration to an NSXMLDocument?
      • From: Bruce Sharpe <email@hidden>
  • Prev by Date: Re: Terminating subtasks reliably
  • Next by Date: Re: Terminating subtasks reliably
  • Previous by thread: Re: How to add a DOCTYPE declaration to an NSXMLDocument?
  • Next by thread: Re: How to add a DOCTYPE declaration to an NSXMLDocument?
  • Index(es):
    • Date
    • Thread