Hello,
Please find below the code. This might be of some
help.
@param duplicateNo: number of times the child has to be
added or duplicated.
@param parent: parent of the duplicate
element
@param duplicateElement: child element which has to be
duplicated
private void duplicateElement(int duplicateNo, Element parent, Element duplicateElement){
try{
int index
= parent.indexOf(duplicateElement);
for(int i=0; i< duplicateNo;
i++)
{
//get the contents from the parent to a local
variable.
Element parentClone = (Element)duplicateElement.clone();
//add the modified element to the parent
element
parent.addContent(index,(Element)parentClone);
index
= parent.indexOf(duplicateElement);
}
//now
remove the parent
element.
parent.removeContent(duplicateElement);
}catch (Exception e) {
e.printStackTrace();
}
}
Regards,
Deepa
Dear all,
who knows on how to add same children element in existing XML file?
Thank you very much for your help.
Regards,
Normadiah Mahiddin