I'm trying to use TinyXML to parse a string with XML format. But the return pointer is always NULL. I'm not sure which part of code is setting wrong.
TiXmlDocument docTemp;
const string strData = "<?xml version=\"1.0\" ?><Hello>World</Hello>";
const char* pTest = docTemp.Parse(strData.c_str(), 0 , TIXML_ENCODING_UTF8);
if(pTest == NULL){
cout << "pTest is NULL" << endl;
}
It always shows 'pTest is NULL' Any idea?
Thanks a bunch!
It should return 0 in the case of an error but looks like there is bug in TiXmlBase::SkipWhiteSpace, if there is no character after the closing bracket it returns 0, but if there is a white space or \r or \n it returns the pointer. So you have 2 options add some white character after the closing bracket or modify the following lines in at the beginning of SkipWhiteSpace:
if ( !p || !*p )
{
return 0;
}
to something like:
if ( !p )
{
return 0;
}
if (!*p)
{
return p;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With