Jay Webster

Jay Webster

  • NA
  • 67
  • 0

Delete Xml

Apr 17 2011 4:41 PM
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)