求教:为什么我在xml里只能删属性的值,删不了属性名??
XmlDocument doc = new XmlDocument();
doc.Load(openFileDialog1.FileName);
XmlElement root = doc.DocumentElement;
root.LastChild.Attributes["id"].RemoveAll();
-------------------------
结果就把 id="234" 变成了 id=""
怎么样能都删掉???
------解决方案--------------------
root.LastChild.Attributes.RemoveNamedItem("id");
doc.Save(openFileDialog1.FileName)
或者
root.LastChild.Attributes.Remove(root.LastChild.Attributes["id"]);