I just started using rapidxml. I 1st create an xml file to read from. Worked so fast an easy.
This is what I manual crated.
I am not sure if this will help but this exists in the documentation:
One quirk is that nodes and attributes do not own the text of their names and values. This is because normally they only store pointers to the source text. So, when assigning a new name or value to the node, care must be taken to ensure proper lifetime of the string. The easiest way to achieve it is to allocate the string from the xml_document memory pool. In the above example this is not necessary, because we are only assigning character constants. But the code below uses memory_pool::allocate_string() function to allocate node name (which will have the same lifetime as the document), and assigns it to a new node.
I can see in your code that it appears that your char arrays x, y, z are created in scope of your loop and as such do not satisfy the requirements above.