Reputation: 337
TiXmlElement *pElem;
std::string StatusResponse;
pElem = hResponse.FirstChild("StatusResponse").Element();
if (pElem)
StatusResponse = pElem->GetText();
If pElem
is valid but the element contains no text, pElem->GetText()
returns a NULL pointer, causing an exception. How should I handle this?
Thanks.
Upvotes: 1
Views: 2881
Reputation: 355207
if (pElem && pElem->GetText())
StatusResponse = pElem->GetText();
Upvotes: 6