Tuesday, May 3, 2011

Copy the XML Document

Hi,

The copy of XML documnet is different from our normal objects. Because while coping the XML documnet it is coping with ref obeject. Means

XMLDocument obj1 = "Some XML documnet or XML document obeject"

XMLDocument obj2 = obj1;

If you make any changes for obj2, same thing will reflect in obj1 also. Because it is having the ref while copying. To avoid this type problems use this for coping

obj2 = (XmlDocument)obj1 .Clone();

It's works better!!

No comments:

Post a Comment