To remove attribute from xml file, you can use following code snippets.
private void RemoveAttribute()
{
XmlDocument xmlDoc = new XmlDocument();
if (File.Exists("myfile.xml"))
{
xmlDoc.Load("myfile.xml");
XmlNodeList list = xmlDoc.GetElementsByTagName("rect");
foreach (XmlNode node in list)
{
node.Attributes.RemoveNamedItem("x");
}
xmlDoc.Save(xmlFile);
}
}
Here, I am trying to remove
x attribute from
rect node of existing xml file.