How to add a DOCTYPE declaration to an NSXMLDocument?
How to add a DOCTYPE declaration to an NSXMLDocument?
- Subject: How to add a DOCTYPE declaration to an NSXMLDocument?
- From: Bruce Sharpe <email@hidden>
- Date: Sat, 27 Mar 2010 16:59:35 -0700
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?
_______________________________________________
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