This works, but depending on what you are attempting to do, it is not
optimal...
What happens here is [some steps cut out for the sake of brevity]:
construct std::string nodeValue.
construct std::string str.
assign a char* to std::string str.
construct a temporary std::string.
assign std::string str to temporary std::string.
destruct std::string str.
assign temporary std::string to std::string nodeValue.
destruct temporary std::string.
destruct std::string nodeValue.
Depending on the contents of a node, this could be a lot of string copying.
Using the other method [some steps cut out for the sake of brevity]:
construct std::string nodeValue.
assign a char* to std::string nodeValue.
destruct std::string nodeValue.
So, it entirely depends on what you are attempting to do...
Thanks,
Anthony Zawacki
410-571-7161
[EMAIL PROTECTED]
"Andreas B. Thun"
<[EMAIL PROTECTED]> To: [EMAIL PROTECTED]
cc:
03/27/2003 11:28 Subject: Re: DOM nodeValues: char* to
string
AM
Please respond to
xerces-c-dev
Thanks a lot for the fast reply!
I have now:
static string getNodeValue(DOMNode *node)
{
char *chNodeValue;
const XMLCh *nodeValue;
string str;
if (node)
{
nodeValue = node->getNodeValue();
chNodeValue = XMLString::transcode(nodeValue);
str = chNodeValue;
XMLString::release(&chNodeValue);
}
return(str);
} // getNodeValue()
Function call:
--------------
string nodeValue;
// ---------------------
// this is not correct?!
// ---------------------
nodeValue = getNodeValue(accessControlGroupChild);
if (nodeValue.length() != 0)
{
// ok, let's do something with nodeValue
}
else
{
// no node value
}
---------------------------------------------------------------------
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]