deleting entire xml node with datagrid
- by DuranL
Hello,
I have the following xml structure:
<systemtest>
<test id="0">
<name>Test One</name>
</test>
<test id="1">
<name>Test Two</name>
</test>
</systemtest>
The name gets displayed in the 1ste colum of the datagrid, where in the 2nd colum there is a buttoncolumn with delete button.
How exactly can i use xpath and navigate to the current node lets say with test id="0" and delete it (including name)?
Its unclear how i can say to this method what row he has to delete exactly.
XmlDocument XMLDoc = new XmlDocument();
XMLDoc.Load(XMLFile);
XPathNavigator nav = XMLDoc.CreateNavigator();
nav.SelectSingleNode("...."); //??
nav.DeleteSelf(); //will this do the trick?
Also the id gets generated in a seperate class where the above method should be.
Thanks in advance.