2
Answers

Delete Xml

Ask a question
Jay Webster

Jay Webster

13y
2.1k
1
Hi,

I have the above XML and code:

XML
<Library>
  <Game id="1">
    <Title>Game1</Title>
    <Description>Test1</Description>
  </Game>
  <Game id="2">
    <Title>Game2</Title>
    <Description>Test2</Description>
  </Game>
</Library>


Code
var deleteNode = doc.SelectSingleNode("//Library/Game[id='1']");
deleteNode.ParentNode.RemoveAll();


I want to remove the following:
  <Game id="1">
    <Title>Game1</Title>
    <Description>Test1</Description>
  </Game>


It should look like this after:
<Library>
  <Game id="2">
    <Title>Game2</Title>
    <Description>Test2</Description>
  </Game>
</Library>


The code doesnt seem to be working though :(

Jay

Answers (2)
Next Recommended Forum