Pila
Pila

Reputation: 679

Update XML file

I want to replace an XML node that is not a child of the root element. How can I do it - not in .NET 3.5?

I don't know the exact path to the node I want to replace, I get the node by XPath query like:

XmlElement root = doc.DocumentElement;
oldItem = root.SelectSingleNode("//Node1[@name='aaa']//Node2[Item='bbb']/Value");

How can I replace this old item?

Upvotes: 2

Views: 171

Answers (1)

Jouke van der Maas
Jouke van der Maas

Reputation: 4338

Use root.SelectSingleNode("query").Value = [New value]

Upvotes: 3

Related Questions