If someone could help me I'd be extremely grateful!
Thank you! :) :) :)
Here is my xml:
<?xml version="1.0" encoding="utf-8"?>
<quotes>
<quote>
<name>Bob</name>
<id>2</id>
</quote>
<quote>
<name>Bob2</name>
<id>4</id>
</quote>
</quotes>
I am using this to try and delete the entire 'quote' node that contains the id of value 4.
XmlDocument doc = new XmlDocument();
doc.Load("contosoBooks.xml");
XPathNavigator navigator = doc.CreateNavigator();
XPathExpression expression;
expression = navigator.Compile("/quotes/quote[id=4]");
XPathNodeIterator Iterator = navigator.Select(expression);
while (Iterator.MoveNext())
{
navigator.DeleteSelf();
}
doc.Save("bob.xml");
But I get: Operation is not valid due to the current position of the navigator....
If their is a better way to delete an xml node please do tell :(
Thank you sooooo much!