As has been mentioned, calls to transcode will leak memory unless it is
released.

We use the following method internally:

void XmlString2StdString(const XMLCh* in, std::string& out)
{
    char* data = XmlString::transcode(in);
    out = data;
    XmlString::release(&data);
}

Additionally, after DOMString was removed, we replaced it with an XmlString
to handle transcoding the other direction, char* -> XMLCh* in which the
class handles transcoding char* to XMLCh*.  The effect of this is that in
all of our code, transcode is only called by these two library routines,
which prevents a lot of memory leak problems.

Thanks,
Anthony Zawacki

410-571-7161
[EMAIL PROTECTED]



                                                                                       
                                             
                      "Andreas B. Thun"                                                
                                             
                      <[EMAIL PROTECTED]>            To:       [EMAIL PROTECTED]       
                                         
                                               cc:                                     
                                             
                      03/27/2003 10:29         Subject:  DOM nodeValues: char* to 
string                                            
                      AM                                                               
                                             
                      Please respond to                                                
                                             
                      xerces-c-dev                                                     
                                             
                                                                                       
                                             
                                                                                       
                                             




Hi!

I am using the following function to retrieve
DOM-node values. But I want to return not (char *),
but a STL string value. How can I do it?

Sorry for that C++ newbie request.
Used to be a C programmer ....
:-)

TIA


#include <string>


static char *getNodeValue(DOMNode *node)
{
    char        *chNodeValue;
    const XMLCh *nodeValue;

    if (node)
    {
       nodeValue = node->getNodeValue();
       chNodeValue = XMLString::transcode(nodeValue);
       // cout << "  '" << chNodeValue << "' " << endl;
    }
    return(chNodeValue);
}  // getNodeValue()


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to