Hi,
Is it a problem that the caller has to delete the returned string?
If it is like below, the caller owns the returned string and then
perhaps it should return a XMLCh* instead of const XMLCh*?
Magnus
// alpha version
const XMLCh* DOMNodeImpl::getTextContent() const
{
DOMNode* thisNode = castToNode(this);
DOMNode* currentNode;
XMLUInt32 nContentLength = 0;
if (!thisNode)
return NULL;
DOMDocument* ownerDoc = thisNode->getOwnerDocument();
if (!ownerDoc)
return NULL;
// Get total length of content
DOMNodeIteratorImpl nodeIterator(ownerDoc, thisNode,
DOMNodeFilter::SHOW_TEXT|DOMNodeFilter::SHOW_CDATA_SECTION, NULL,
false);
currentNode = nodeIterator.nextNode();
while (currentNode)
{
nContentLength +=
XMLString::stringLen(currentNode->getNodeValue());
currentNode = nodeIterator.nextNode();
}
// Allocate buffer
XMLCh* pzContentStr = new XMLCh[nContentLength+1];
if (!pzContentStr)
return NULL;
*pzContentStr = 0;
// Fetch content
DOMNodeIteratorImpl nodeIterator2(ownerDoc, thisNode,
DOMNodeFilter::SHOW_TEXT|DOMNodeFilter::SHOW_CDATA_SECTION, NULL,
false);
currentNode = nodeIterator2.nextNode();
while (currentNode)
{
// does this have to be thread safe? if another thread
inserts a node the buffer will be too small
XMLString::catString(pzContentStr,
currentNode->getNodeValue());
currentNode = nodeIterator2.nextNode();
}
return pzContentStr;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]