Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 479475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:47:46+00:00 2026-05-13T00:47:46+00:00

I see there are other questions related to this, but none using NSXML. So,

  • 0

I see there are other questions related to this, but none using NSXML.

So, I’m constructing an XML document from scratch using NSXML and when I create a NSXMLNode with a string value, all the “<” characters in that string are replaced with “& lt;” when I output the node, or save it to a file.

Example:

 NSXMLNode *description = [NSXMLNode elementWithName:@"description"
                               stringValue:@"<![CDATA[Some Description</a>]]>"];

Then when I do

 NSLog(@"description: %@", description);

I get the node with all the ‘<‘ characters replaced with “& lt;”. However when I do

 NSLog(@"description string value: %@", [description stringValue]);

I get the correct string output. This XML document is going to be saved as a KML file for google earth, and google earth gives me an error when it finds the “& lt;” token. Any idea how to make NSXML just output the ‘<‘? I’m using OSX 10.6 and XCode 3.2 btw.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T00:47:47+00:00Added an answer on May 13, 2026 at 12:47 am

    There’s a special options flag for indicating CDATA that will help here. The trick is to let cocoa write the <![CDATA[ and ]] bookends for you:

    NSXMLNode *cdata = [[[NSXMLNode alloc] initWithKind:NSXMLTextKind
                                                options:NSXMLNodeIsCDATA] autorelease];
    [cdata setStringValue:@"Some CDATA Description"];
    
    NSXMLElement *description = [NSXMLNode elementWithName:@"description"];
    [description addChild:cdata];
    
    NSLog(@"description: %@", description);
    
    // yields: <description><![CDATA[Some CDATA Description]]></description>
    

    To obtain a string with the angle brackets intact:

    NSString *output = [description XMLString];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are other related questions e.g. 6624113 , 3403909 , 4516891 but my question
(I see several questions related to my problem but none of the solutions work
I see that there are A LOT of related questions on this one, and
I've read a couple of related questions on this, but they don't answer my
Lots of style-related jquery autocomplete questions (yow), but none that want to "match the
I understand there are many questions related to this, so I'll be very specific.
This is related to some other questions, such as: this , and some of
I see there are techniques available to have deep models in Backbone, but how
I see there is a question here but there is no definite answer. Has
I see there is version 1.5 and 3.0 beta , but I can't seem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.