XDocument doc = XDocument.Load("example.xml"); // Find the element to clone XElement originalElement = doc.Descendants("elementToClone").FirstOrDefault(); // Clone the element and assign it to a new variable XElement clonedElement = new XElement(originalElement); // Modify the cloned element clonedElement.SetAttributeValue("attributeName", "newValue"); // Add the cloned element to the document doc.Root.Add(clonedElement); doc.Save("modified.xml");This code searches for an element with the name "elementToClone" in an XML file called "example.xml". It then creates a copy of the element using the XElement constructor and assigns it to a new variable. This new element can then be modified, in this case by changing the value of an attribute. Finally, the cloned element is added to the root of the document and saved to a new file called "modified.xml". In this example, the XDoc package library is used to load, manipulate, and save XML documents.