Re: NSXML and Character References
Re: NSXML and Character References
- Subject: Re: NSXML and Character References
- From: Ilan Volow <email@hidden>
- Date: Mon, 21 Nov 2005 17:19:52 -0500
I have had some problems with < and > being escaped as well. I had
assumed it was a bug in NSXML stuff.
On Nov 21, 2005, at 10:26 AM, Juan Alvarez wrote:
Hi,
I am creating an NSXMLDocument and adding the children as
NSXMLNodes. The problem I am having is that the xml being written
out escapes only "&" characters and not apostrophes or quotations.
Why is that? Is there a way to have all the characters escape
properly. I have already tried to replace the characters with the
appropriate escaping, but for some reason the xml still wants to
escape the & character that are in there. Please help. I have
provided sample code below and the ouput:
Code:
NSXMLElement *root = (NSXMLElement *)[NSXMLNode
elementWithName:@"rss"];
NSXMLDocument *xmlDoc = [[NSXMLDocument alloc]
initWithRootElement:rootElement];
[xmlDoc setVersion:@"1.0"];
[xmlDoc setCharacterEncoding:@"UTF-8"];
NSXMLNode *node = [NSXMLNode elementWithName:@"title"];
[node setStringValue:@"My \"Mom\" & \"Dad's\" Show"];
[root addChild:node];
NSData *data = [xmlDoc XMLDataWithOptions:NSXMLNodePrettyPrint];
[data writeToFile:filepath atomically:YES];
Output:
<?xml version="1.0" encoding="UTF-8"?>
<rss>
<title>My "Mom" & "Dad's" Show</title>
</rss>
See the quotations and the apostrophe are not being converted to
" and ' respectively. Only the ampersand is being
converted. Thanks for your help.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden