Thanks for the answer, i have put in the missing lines to your code, so it looks like this:
//.......
//Having that "pElement" is the "Name" element:
XMLElement *pElement = xmlEvent.GetRootElement()->GetChildren()[1]->FindElementZ("Name");
unsigned int uiContentsNum=pElement->GetContentsNum();
char *szContent;
int iLContent=0;
if(uiContentsNum>0)
{
XMLContent *pContent=pElement->GetContents()[0];
//First we get the lenght
unsigned int uiLContent=pContent->GetValue(NULL);
//Then we reserve the memory and get the content value.
szContent=new char[iLContent+1];
pContent->GetValue(szContent);
cout << "szContent=something" << endl;
}
else
{
szContent=NULL;
cout << "szContent=NULL" << endl;
}
but my program still crashes if there is no <name> element in the child that i'm searching in.
e.g. if i look for name in this element, the code would crash:
<Variable>
<Description>Is used for...</Description>
</Variable>