Given the following XML:
<SomeXML>
<Element1>
<Element2 Attribute3="Value4" />
</Element1
</SomeXML>
… and an XElement reference to ‘SomeElement’ and an XPath ‘Element1/Element2/@Attribute3’
How do I retrieve a reference to Attribute3 so that I may alter it’s value (using the Xpath)?
The XPath is to be a retrieved setting and thus is my only way of locating the node in question.
Add
using System.Xml.XPathto the code file where you need to do this.Then you can use code like this:-