tags:

views:

1871

answers:

2

Using C#

How do you remove a specific node from an XMLDocument using XPATH?

+1  A: 

Here you go. ChildNodeName, could be just the node name or an XPath query.

XmlDocument doc = new XmlDocument();

// Load you XML Document

XmlNode childNode = doc.SelectSingleNode(childNodeName);

// Remove from the document
doc.RemoveChild(childNode);

There is a different way using Linq, but I guessed you were using .NET 2.0

David Basarab
+2  A: 

XPath can only select nodes from a document, not modify the document.

Oliver Hallam