You can update Duplicate xml nodes by using the below method
public static bool UpdateDuplicateXml(string xmlFilePath)
{
try
{
XDocument xml = XDocument.Load(xmlFilePath);
var dubs = xml.Descendants().Where(x => x.Name == "author");
var xElements = dubs as XElement[] ?? dubs.ToArray();
if (xElements.Count() > 1)
{
for (int index = 0; index < xElements.Length; index++)
{
if (index == 0)
{
XElement xElement = xElements[index];
xElement.Name = xElement.Name;
}
else
{
XElement xElement = xElements[index];
int newIndex = index + 1;
xElement.Name = xElement.Name + newIndex.ToString();
}
}
}
xml.Save(xmlFilePath);
return true;
}
catch(Exception exception)
{
return false;
}
}
Hope this helps