My XML file:
<?xml version="1.0" encoding="utf-8"?>
<WebServices>
<WebService>
<Name>ServiceA</Name>
<Uri>http://localhost:53683/api/home</Uri>
</WebService>
<WebService>
<Name>ServiceB</Name>
<Uri>http://localhost:50043/api/home</Uri>
</WebService>
</WebServices>
I want to delete node by Name. My code doesn't work.
XDocument document = XDocument.Load(this.Path);
//xDoc.Element("WebServices").Element("WebService").Elements("Name").Where(node => node.Value == "Name1").Remove();
document.Save(this.Path);
It removes only "Name" node in WebService. I want to remove the "WebService" node from "WebServices". Any one can help?