You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by David Webber <da...@musical.demon.co.uk> on 2013/03/06 13:26:47 UTC
Re: How to convert DOMNode to std::string?
From: Renato Forti
>I need convert DOMNode* into std::string! How I can do this,
For a DOMNode containing #PCDATA, off the top of my head, something like:
std::wstring xmlContainedString( const DOMNode *pNode )
{
std::wstring sResult;
if( !pNode ) return sResult; // Error => empty string.
DOMNode *pText = pNode->getFirstChild();
if( pText && (pText->getNodeType() == DOMNode::TEXT_NODE) )
sResult =
pText->getNodeValue();
return sResult;
}
And BTW I recommend always using wide strings (std::wstring)
Dave
David Webber
Mozart Music Software
http://www.mozart.co.uk/