Hi
I am currently loading xml from files and all is working fine. The code is as follows (only the logic part. there is error handling as well):
bool Utils::GetRootElement( const char* xmlFileName, TiXmlElement** element ) { TiXmlDocument xmlDoc( xmlFileName ); bool res = xmlDoc.LoadFile(); if( res ) { *element = (TiXmlElement*)xmlDoc.RootElement()->Clone(); return true; } }
Now I need to read the xml from a string. I do the following:
bool Utils::GetRootElementFromString( const char* sXmlString, TiXmlElement** element ) { TiXmlDocument xmlDoc; const char* res = xmlDoc.Parse(sXmlString, 0, TIXML_ENCODING_UTF8); if( res == NULL ) { *element = (TiXmlElement*)xmlDoc.RootElement()->Clone(); return true; } }
RootElement is created badly
What am I doing wrong?
Log in to post a comment.
Hi
I am currently loading xml from files and all is working fine. The code is as follows (only the logic part. there is error handling as well):
Now I need to read the xml from a string. I do the following:
RootElement is created badly
What am I doing wrong?
Last edit: haber5 2013-05-23