First you need to understand what goes in the DOM. In your example, the first child of the SupplementalAction element is a text node containing whitespace. Then comes the character data, then more whitespace. If all you're interested is the contents of the CDATA section, traverse the list of children using DOMNode::getFirstChild() and DOMNode::getNextSibling(). Use DOMNode::getNodeType() to check the type of each node, and when you find one whose type is DOMNode::CDATA_SECTION_NODE, cast it to DOMCharacterData and call DOMCharacterData::getData(). (I'm not 100% certain of that last step, not having done that bit myself.)
Alternately, DOMNode::getTextContent() might serve your purposes. -----Original Message----- From: Mihai Matei [mailto:[EMAIL PROTECTED] Sent: Monday, May 14, 2007 11:25 AM To: [email protected] Subject: How can I get the contents of a CDATA section? Hi, sample file: <?xml version="1.0" encoding="UTF-8"?> <test> <SupplementalAction> <![CDATA[#!/usr/bin/ksh other stuff ]]> </SupplementalAction> </test> sample code that does not work: DOMNode *temp = pDoc->getElementsByTagName(X("SupplementalAction"))->item(0); const XMLCh* contents = temp->getFirstChild()->getNodeValue(); char* strValue = XMLString::transcode(contents); std::cout << "\nCDATA:" <<strValue; What am I doing wrong? Any help appreciated. Is there any way of printing the in-memory DOM structure? Thanks. ________________________________________________________________________ ____________ Finding fabulous fares is fun. Let Yahoo! FareChase search your favorite travel sites to find flight and hotel bargains. http://farechase.yahoo.com/promo-generic-14795097
