当前位置: 代码迷 >> ASP.NET >> 为什么小弟我在xml里只能删属性的值,删不了属性名?
  详细解决方案

为什么小弟我在xml里只能删属性的值,删不了属性名?

热度:9088   发布时间:2013-02-25 00:00:00.0
求教:为什么我在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"]);
  相关解决方案