| Issue 45: | CDATA support | |
| 6 people starred this issue and may be notified of changes. | Back to list |
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
Aug 10, 2009
NEED CDATA
Aug 31, 2009
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
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
|
Owner: jwight
Labels: -Type-Defect -Priority-Medium Type-Enhancement Priority-High TouchXML