senjuhashirama / pugixml

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

Problem In clone #174

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I am trying to clone node. But fails. 
I am using following code

class CXmNode
{
pugi::xml_node m_XmlNode;
}
Clone(const CXmlNode& sourceNode)
{
   pugi::xml_node tempNode;
   const pugi::char_t* nodeName;

   const CXmlNode& newNode = sourceNode;
   pugi::xml_node newXmlNode;

   retVal = OK;
   nodeName = newNode.m_XmlNode.name();
   newXmlNode = sourceNode.m_XmlNode;
   tempNode = newXmlNode.append_child(nodeName);

   if(NULL == tempNode)
   {
      return error;
   }
   return ok;
}

Original issue reported on code.google.com by kshitija...@gmail.com on 19 Sep 2012 at 9:00

GoogleCodeExporter commented 9 years ago
I don't see any errors in the code per se; note that you're appending a child 
with name sourceNode.name() to sourceNode, so what you'll get is

<node />
->
<node><node /></node>

This code will fail if newXmlNode (i.e. sourceNode.m_XmlNode) is NULL or if it 
has the type that is not pugi::node_element (you can get the type using type() 
accessor).

Original comment by arseny.k...@gmail.com on 19 Sep 2012 at 4:22

GoogleCodeExporter commented 9 years ago
Thanks. Solved my problem
kshitija

Original comment by kshitija...@gmail.com on 25 Sep 2012 at 12:13

GoogleCodeExporter commented 9 years ago

Original comment by arseny.k...@gmail.com on 25 Sep 2012 at 3:54