deleting entire xml node with datagrid

Posted by DuranL on Stack Overflow See other posts from Stack Overflow or by DuranL
Published on 2010-12-25T12:25:38Z Indexed on 2010/12/25 12:54 UTC
Read the original article Hit count: 240

Filed under:
|
|
|

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.

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET