当我尝试使用 RemoveChild() 删除我的一些子元素时。但是抛出异常。我在下面附上了我的代码。
nodeName = doc.SelectSingleNode("//Equipment//DataCollections//EnabledIDs//MyID[@id='" + attrValue + "']");
// Found the nodeName successfully druing run time.
doc.DocumentElement.RemoveChild(nodeName);
// faild to Remove the node
在下面显示错误:
An unhandled exception of type 'System.ArgumentException' occurred in System.Xml.dll
Additional information: The node to be removed is not a child of this node.
如何删除节点?
[更新]
使用 VS2005 和 .NET 2.0。