rapidXML, corrupted memory when traversing DOM tree
<p>Don't understand what is going on with the attribute's memory and rapidXML.
A function encapsulates the xml parsing, if success, returns a reference to the root node, when calling the traverse DOM tree inside this function I get the correct data stored in an xml file.</p>

<pre><code> typedef rapidxml::xml_node&lt;&gt;* Node;
 ...
 Node Load()
 {
     Node pRootNode = NULL;
     // read file stream in bytes
     ...
     std::vector&lt;char&gt; xmlCopy(bytes.begin(), bytes.end());
     xmlCopy.push_back('\0');
     rapidxml::xml_document&lt;&gt; doc;

    try
    {
      doc.parse&lt;rapidxml::parse_declaration_node | rapidxml::parse_no_data_nodes&gt;(&amp;bytes[0]);
      pRootNode = doc.first_node();
          ...
          TraverseDOMTree(pRootNode);
    }
    return pRootNode;
 }
</code></pre>

<p>TraverseDOMTree prints all attributes and node names as expected.</p>

<p>Later, obviously outside the scope of Load, pRootNode will be used to query values from the DOM three, this doesn't work.
For testing purposes calling TraverseDOMTree, which perfectly worked, now prints attribute's garbage values. I can assume the DOM tree is still there, the same hierarchy of nodes as in the first call, but the attributes values are messed up.
I tried making the <strong>rapidxml::xml_document&lt;> doc</strong> global and also adding the <strong>parse_non_destructive</strong> flag, none of those make a difference.</p>

<p>If matters, the client using the Load method is running in the same thread. What can be wrong?</p>
