Th3Ya0vi / pugixml

Automatically exported from code.google.com/p/pugixml
0 stars 0 forks source link

Clone node #178

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I am trying to clone the node. not appending that clonned node.
Just copying. But it fails. It is copying the node, but when i try to update 
the clonned node it is updating the source node also.
Following code I am using:
CXmlNode
{
pugi::xml_node m_XmlNode;
}
Clone(const CXmlNode& sourceNode)
{
   pugi::xml_node tempNode;
   const pugi::char_t* nodeName;
   std::auto_ptr<ILog> log(new MockLog());

   CXmlNode newNode(*log);
   pugi::xml_node* newXmlNode = new pugi::xml_node;

   memcpy(&newNode, &sourceNode,sizeof(sourceNode));
   newXmlNode = &newNode.m_XmlNode;
   m_XmlNode = *newXmlNode;

   if(NULL == m_XmlNode)
   {
       return error;
   }
   return OK;
}

other than memcpy() i tried following code also but same output.

m_XmlNode = sourceNode.m_XmlNode;

Please help me

Original issue reported on code.google.com by kshitija...@gmail.com on 26 Sep 2012 at 12:07

GoogleCodeExporter commented 8 years ago

Original comment by arseny.k...@gmail.com on 26 Sep 2012 at 4:05