I'm trying to read string data from an XML file, but I get a strange result. If the string to be read is longer than 15 characters I get an "invalid pointer" assertion in the file "dbgheap.c" at program shutdown. The problem shows both when I'm trying to read a string attribute and a text node.
For simplicity I'll report just the case of the text node. Here is the code I call to read the text of the "Content" node. "SearchHierarchy" just navigates the DOM looking for a specified node and returns a pointer to it.
This code is successful, and the data is correctly read. The problem shows at program shutdown and only when the read string is longer than 15 characters. I'm using Visual Studio 2003 .NET under WinXP.
Any suggestion, please?
Thank you,
TheDark.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm trying to read string data from an XML file, but I get a strange result. If the string to be read is longer than 15 characters I get an "invalid pointer" assertion in the file "dbgheap.c" at program shutdown. The problem shows both when I'm trying to read a string attribute and a text node.
This is my sample XML
<?xml version="1.0" ?>
<MyApp>
<!-- Settings for MyApp -->
<Content>
1234567890abcde
</Content>
<Windows>
<Window name="MainFrame0abcdef" x="5" y="15" w="400" h="250" />
</Windows>
</MyApp>
For simplicity I'll report just the case of the text node. Here is the code I call to read the text of the "Content" node. "SearchHierarchy" just navigates the DOM looking for a specified node and returns a pointer to it.
bool Load(const std::string& elementName, std::string& destination)
{
// Search for the element.
TiXmlElement* pElem = SearchHierarchy(elementName);
if( pElem == NULL )
return false;
// Make the query.
TiXmlNode* textElem = pElem->FirstChild();
if( textElem == NULL )
return false;
TiXmlText* text = textElem->ToText();
if( text == NULL )
return false;
destination = text->ValueStr();
if( !destination.empty() )
return true;
return false;
}
This code is successful, and the data is correctly read. The problem shows at program shutdown and only when the read string is longer than 15 characters. I'm using Visual Studio 2003 .NET under WinXP.
Any suggestion, please?
Thank you,
TheDark.
I think so you can overcome with string reading problems via practice. Thanks