My favorites | Sign in
Project Home
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 45: CDATA support
6 people starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  jwight
Closed:  Mar 2010


 
Reported by timwnit...@gmail.com, Jan 29, 2009
What is the expected output? What do you see instead?
This would be a support helpful addition.  Currently the CDATA tags are unsupported.

What version of the product are you using? On what operating system?
iPhone 2.2.1

Please provide any additional information below.
medium


Apr 18, 2009
Project Member #1 jwight
r285 added initial support for CDATA - enough to treat CDATA as strings. Is this enough for folks?
Status: Started
Owner: jwight
Labels: -Type-Defect -Priority-Medium Type-Enhancement Priority-High TouchXML
Aug 10, 2009
#2 serg.f...@gmail.com
NEED CDATA
Aug 31, 2009
#3 hishands...@gmail.com
Would be nice to have a bit more support:

For example, the following chunk of code:

	NSString * xml = @"<?xml version=\"1.0\" encoding=\"UTF-8\"?
><MyRootElement><MyChildElement><Title><![CDATA[I am some CDATA 
text.]]></Title></MyChildElement></MyRootElement>";
	CXMLDocument * document = [[CXMLDocument alloc] initWithXMLString: xml options: 
CXMLDocumentTidyXML error: nil];
	NSLog(@"%@", [document XMLString]);

Produces:

<MyRootElement><MyChildElement><Title></Title></MyChildElement></MyRootElement>

Into the same NSXMLDocument:

	NSString * xmlString = @"<?xml version=\"1.0\" encoding=\"UTF-8\"?
><MyRootElement><MyChildElement><Title><![CDATA[I am some CDATA 
text.]]></Title></MyChildElement></MyRootElement>";
	NSXMLDocument * document = [[NSXMLDocument alloc] initWithXMLString: xmlString options: 
NSXMLDocumentTidyXML error: nil];
	NSLog(@"%@", [document XMLString]);

You get:

<?xml version="1.0" encoding="UTF-8"?><MyRootElement><MyChildElement><Title>I am some CDATA 
text.</Title></MyChildElement></MyRootElement>


I've not had a chance to look into the reason yet, but it would be nice to get the content of the Title element.  
Great library otherwise though!
Mar 19, 2010
Project Member #4 jwight
CData support is in place:

NSError *theError = NULL;
CXMLDocument *theXMLDocument = [[[CXMLDocument alloc] 
initWithXMLString:@"<xml><![CDATA[<sender>John Smith</sender>]]></xml>" options:0 error:&theError] 
autorelease];
NSLog(@"%@", theXMLDocument);
CXMLElement *theRootElement = [theXMLDocument rootElement];
NSLog(@"%@", [theRootElement name]);
NSLog(@"%@", [theRootElement stringValue]);
CXMLNode *theNode = [[theRootElement children] lastObject];
NSLog(@"%@", [theNode stringValue]);

GIves:

2010-03-19 08:15:40.450 TouchXML_Demo[24448:a0f] <CXMLDocument 0x105b40 [0x106600]> <?xml 
version="1.0"?>
<xml><![CDATA[<sender>John Smith</sender>]]></xml>
2010-03-19 08:15:40.452 TouchXML_Demo[24448:a0f] xml
2010-03-19 08:15:40.453 TouchXML_Demo[24448:a0f] <sender>John Smith</sender>
2010-03-19 08:15:40.456 TouchXML_Demo[24448:a0f] <sender>John Smith</sender>

Status: Fixed

Powered by Google Project Hosting