You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by Thomas Zabel <th...@gmx.net> on 2003/11/28 13:07:00 UTC

getnodevalue of CDATASection - Problem.....

Hello,

I'am  a xalan-c-newbie. perhaps someone here can help me or has occured the
same problem.....
I give you a code-example......
first I give you the XML-source of the node, that has to be evaluated......


       <HEADLINE><![CDATA[TecDAX am Morgen: Rote Vorzeichen, LION verliert
über 8 Prozent]]></HEADLINE>


now comes the C++-Source-Code:
----------------------------

       // first I evaluate an XPath-expression........   
       XalanNode *context=theWrapper.getDocumentElement();
       XalanNode *result=theEvaluator.selectSingleNode(theDOMSupport,
                                                   context,
                                                  
XalanDOMString(xpathtonode).c_str());

       // now I have a XercesNode
       DOMNode* xerNode= (DOMNode*)(theWrapper.mapNode(result));
        

        // and now i want to print the text-content of the CDATA-section
       if(result->getFirstChild()->getNodeType() ==
DOMNode::CDATA_SECTION_NODE)
       {
           cout << "CDATA_SECTION_NODE\n";
           cout <<  "content:" <<
XMLString::transcode(result->getFirstChild()->getNodeValue();
       }
   
the output  of this programme is like this:
--------------------------------


        CDATA_SECTION_NODE
        content:       (<-------- NOTHING!!!!!!!     WHY???? )


you see, I can't get the content of the CData-section withe getNodeValue. I
tried everything: getTextContent(), I casted to a CharacterDataNode and
tried
.getData(), nothing helped. it is , as if the CDATA-section contains
nothing.....

if I serialize the same node with a DOMWriter to a   StdOutFormatTarget the
CDATA-node  is printed.
but I need the only the content.........
it seems to me, as I do nothing wrong, am I right? what could be the reason
????????? is it due to the mapping from xalan? what are alternative ways, if
this way to get the content doesnt'work?
Please help me!!!!!

Many Thanx in advance and regards
Thomas

















-- 
NEU FÜR ALLE - GMX MediaCenter - für Fotos, Musik, Dateien...
Fotoalbum, File Sharing, MMS, Multimedia-Gruß, GMX FotoService

Jetzt kostenlos anmelden unter http://www.gmx.net

+++ GMX - die erste Adresse für Mail, Message, More! +++