I’ve got an XML file that looks like this:
...
<body>
<unit id="1" name ="xxx">
<sourceFile>SomeFile.xml</sourceFile>
<targetFile/>
</unit>
<unit id="2" name ="xxx">
<sourceFile>SomeFile.xml</sourceFile>
<targetFile/>
</unit>
</body>
Can someone show me how I would use LINQ to XML via C# to read the value of the sourceFile node, and update the value of targetFile as I’m not familiar with LINQ to XML?
Thanks.
Something like this:
Alternatively:
(And call
doc.Saveafterwards if you want to save back to a file, of course, as pointed out in another answer.)