• 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 >
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSXML and >


  • Subject: Re: NSXML and >
  • From: Keith Blount <email@hidden>
  • Date: Tue, 9 Feb 2010 13:03:12 -0800 (PST)

Great, many thanks for the reply, and for the location of the information in the XML docs, that's very helpful. Unfortunately, it seems that the NSXML classes don't fix the '>' in the ']]>' case either, though:

NSXMLElement*element = [[[NSXMLElementalloc] initWithName:@"Test"stringValue:@"< & > ]]>"] autorelease];
NSLog (@"%@", element);

Output:

<Test>&lt; &amp; > ]]></Test>

So presumably that means that, given that the docs say &gt; may be used, I am going to need to fix this anyway. (Even though it's unlikely the "]]>" combination will come up, I can't rule it out as this is user-generated data).

Many thanks again and all the best,
Keith


----- Original Message ----
From: glenn andreas <email@hidden>
To: Keith Blount <email@hidden>
Cc: "email@hidden" <email@hidden>
Sent: Tue, February 9, 2010 8:52:40 PM
Subject: Re: NSXML and >

The XML spec does not require '>' to be escaped as '&gt;' (except in the case of ']]>' when that doesn't mark the end of a cdata section).  Only '&' and '<' must be escaped - see section 2.4 of XML 1.0 spec.


Sent from my iPhone

On Feb 9, 2010, at 2:19 PM, Keith Blount <email@hidden> wrote:

> Hello,
>
> I'm using the NSXML classes to write out various strings, and it seems that these classes convert "<" to "&lt;" but not ">" to "&gt;", which I find odd. For instance, consider the following code snippet:
>
> NSXMLElement*element = [[[NSXMLElementalloc] initWithName:@"Test"stringValue:@"< & >"] autorelease];
> NSLog (@"%@", element);
>
> The output is:
>
> <Test>&lt; &amp; ></Test>
>
> Is this correct, or is this a bug? Or am I missing something? Do I therefore need to replace all occurrences of ">" with "&gt;" myself to generate better XML?
>




_______________________________________________

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: NSXML and >
      • From: Jens Alfke <email@hidden>
References: 
 >NSXML and &gt; (From: Keith Blount <email@hidden>)
 >Re: NSXML and &gt; (From: glenn andreas <email@hidden>)

  • Prev by Date: Re: NSXML and &gt;
  • Next by Date: Running NSURLConnection from within an NSOperation?
  • Previous by thread: Re: NSXML and &gt;
  • Next by thread: Re: NSXML and >
  • Index(es):
    • Date
    • Thread