I am using a library, RapidXML, but my problem is more general. The library parses xml like item->first_node("CRAP")->first_node("CRAP")
Now, if I put this in an if
statement it will crash. If I put this: item->first_node("CRAP")
it won't.
I am a beginner in C++ and I don't know much about exceptions but:
try
{
if(item->first_node("CRAP")->first_node("CRAP"))
{
}
cout << "OK";
} catch (...)
{
cout << "CRASH";
}
The above crashes. How to check if my node exists without crashes (and without looping all the items one by one)?