RE: NSXML encoding question...
RE: NSXML encoding question...
- Subject: RE: NSXML encoding question...
- From: "John Stiles" <email@hidden>
- Date: Sun, 26 Aug 2007 12:10:17 -0700
- Thread-topic: NSXML encoding question...
A CDATA block is probably the correct way to go here.
I would still caution that one could construct valid C, ObjC or C++ code that contained "]]>" in it, so you still need to be a bit careful...
if( [a multiplyWith:[b value]]>25 )
{
NSLog(@"whoops! CDATA trouble");
}
Unfortunately I don't have a lot of CDATA experience so I don't know the best workaround for this sort of situation.
Personally I've always just written a quick function which replaces < > & in a string with the appropriate XML entities. In fact Cocoa may already have such a function handy; not sure. (My XML parsing code has always needed to be cross platform.)
________________________________
From: cocoa-dev-bounces+jstiles=email@hidden on behalf of James Bucanek
Sent: Sun 8/26/2007 9:24 AM
To: Martin Linklater
Cc: email@hidden
Subject: Re: NSXML encoding question...
Martin Linklater <mailto:email@hidden> wrote (Sunday,
August 26, 2007 5:05 AM +0100):
><code>
>addr = *PC + ( *(PC + 1) << 8);
></code>
As others have pointed out, it's '<'. XML entities have the
general form '&' <entity description> ';', where the description
can be the name of a named entity or a literal constant (i.e. '<').
However, if you want to encode literal data that may, or may
not, contain reserved XML characters it's easier to use a CDATA block:
<code>
<![CDATA[
addr = *PC + ( *(PC + 1) << 8); // & other
<code>crazy</code> stuff!
]]>
</code>
Everything between '<![CDATA[' and ']]>' is read as a literal
string of characters and is not interpreted as XML.
--
James Bucanek
_______________________________________________
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
_______________________________________________
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