Note that there are some explanatory texts on larger screens.

plurals
  1. POtinyxml c++ using TiXmlText in storing integer data
    primarykey
    data
    text
    <p>as per the class reference the TixmlText takes const char* values as input. i need to store integer data read from a text file into xml. the integer data is stored in int vector and each element of the vector is converted to const char* before passing it to Tixml text function.</p> <pre><code>const char* intToXmlChar(int num) { stringstream abc; string value; abc&lt;&lt;num; value=abc.str(); const char* ret_val = value.c_str(); //char* conv_val = const_cast&lt;char*&gt;(ret_val); return ret_val; } </code></pre> <p>But when i finally see the generated xml document. i get garbage values in the element where i save the number</p> <p><code>&lt;timestamp&gt;1&amp;#x00;504&lt;/timestamp&gt;</code></p> <p>how do we store integer data properly?</p> <p>i had traced the where the problem was happening to an extent in the tinyxml.h </p> <pre><code>class TiXmlNode : public TiXmlBase </code></pre> <p>the function </p> <pre><code>void SetValue(const char * _value) { printf(" pre ---number--- %s using this \n",_value); //-- if the value is say 18504 value = _value; printf(" post ---number--- %s using this \n",_value); //-- becomes 1&amp;#x00;504 saved in xml } </code></pre> <p>where the value is of the same <code>class TiXmlNode</code><br> being <code>TIXML_STRING value;</code></p> <ul> <li><strong>Question:</strong> Am i missing some thing very simple?</li> <li><strong>Question:</strong> How can i store the integer data properly</li> </ul> <p>Edit: Thanks for the answers from the docs a point which i missed Use the compile time define:</p> <blockquote> <p>TIXML_USE_STL</p> <p>to compile one version or the other. This can be passed by the compiler, or set as the first line of "tinyxml.h".</p> <p>Note: If compiling the test code in Linux, setting the environment variable TINYXML_USE_STL=YES/NO will control STL compilation. In the Windows project file, STL and non STL targets are provided. In your project, <strong>It's probably easiest to add the line "#define TIXML_USE_STL" as the first line of tinyxml.h.</strong></p> </blockquote> <p><a href="http://www.grinninglizard.com/tinyxmldocs/classTiXmlText.html" rel="nofollow">Tinyxml class ref</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload