• 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: NSXML and Character References
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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" &amp; "Dad's" Show</title>
</rss>

See the quotations and the apostrophe are not being converted to &quot; and &apos; 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
References: 
 >NSXML and Character References (From: Juan Alvarez <email@hidden>)

  • Prev by Date: Re: Obtaining an array of the names of the attributes and relations of a class
  • Next by Date: Re: Distributed Objects - which frameworks?
  • Previous by thread: Re: NSXML and Character References
  • Next by thread: Notification when change is made to the date or time of the System
  • Index(es):
    • Date
    • Thread