The node value pointer (wsz in your code) should remain valid until you
release the node or setting the node's node value to something else or
delete the document.   See
http://xml.apache.org/xerces-c/program-dom.html#XMLCh for details.

Tinny


----- Original Message -----
From: "David Hoffer" <[EMAIL PROTECTED]>
To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
Sent: Friday, November 22, 2002 7:13 PM
Subject: DOM buffer allocation question


> Where is the buffer(string) allocated which is returned by the XMLCh
pointer
> of the getNodeValue() function?  Do I have to provide my own buffer, like
I
> do below, to copy the contents of the returned string into?  Or could I
just
> return the XMLCh pointer from my GetElementValue() method?
>
> BOOL CDOMParser::GetElementValue(const XMLCh* wszTagName, CString&
> strTagValue, const DOMElement* pParentDOMElement)
> {
> ASSERT(pParentDOMElement);
> if (pParentDOMElement)
> {
> DOMNodeList* pDOMNodeList =
> pParentDOMElement->getElementsByTagNameNS(NULL, wszTagName);
> if (!pDOMNodeList || pDOMNodeList->getLength() < 1)
> return FALSE;
>
> DOMNode* pDOMNode = pDOMNodeList->item(0);
> if (pDOMNode)
> {
> DOMNode* pChildNode = pDOMNode->getFirstChild();
> if (pChildNode)
> {
> // What is the scope of the buffer(string) returned by this pointer?  Do
> I have
> // to copy this into my buffer which is passed in by reference?
> XMLCh* wsz = pChildNode->getNodeValue();
> strTagValue = wsz;
> }
> }
>
> return TRUE;
> }
>
> return FALSE;
> }
>
>
>
> ---------------------------------------------------------------------
> 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