I can remove an xml node using
XmlNode node = newsItem.SelectSingleNode("XYZ");
node.ParentNode.RemoveChild(node);
But what if I want to remove multiple nodes at once, for example XYZ,ABC,PQR?
Is there any way to remove all of these nodes at once or do I have to remove them one by one?
NOTE: XYZ,ABC,PQR being at the same level(i.e they all have same parent)
Nothing is inbuilt when using the
XmlDocumentAPI, but you could write a utility extension method, for example:then call:
If you can change to the
XDocumentAPI, then things may be different.