/// <summary> /// It creates a new element copying all attributes from eleToClone; the new /// element is inserted under the parent element provided. /// </summary> /// <param name="parent">Parent element. If null the element is added under the root.</param> /// <param name="eleToClone">Element to be cloned</param> /// <returns></returns> public SvgElement CloneElement(SvgElement parent, SvgElement eleToClone) { // calculate unique id string sOldId = eleToClone.GetAttributeStringValue(SvgAttribute._SvgAttribute.attrCore_Id); string sNewId = sOldId; if (sOldId != "") { int i = 1; // check if it is unique while (GetSvgElement(sNewId) != null) { sNewId = sOldId + "_" + i.ToString(); i++; } } // clone operation SvgElement eleNew = AddElement(parent, eleToClone.getElementName()); eleNew.CloneAttributeList(eleToClone); if (sNewId != "") { eleNew.SetAttributeValue(SvgAttribute._SvgAttribute.attrCore_Id, sNewId); } if (eleToClone.getChild() != null) { eleNew.setChild(CloneElement(eleNew, eleToClone.getChild())); if (eleToClone.getChild().getNext() != null) { eleNew.getChild().setNext(CloneElement(eleNew, eleToClone.getChild().getNext())); } } return(eleNew); }