i have an XML like this
<main>
<reportPath>d:\reports</reportPath>
<errorPath>D:\Error</errorPath>
<project>D:\xyz.txt</project>
<value />
</main>
here "value" is an empty node. using Xpath navigator, I am able to reach Value node, but not able update it. using something like :
XPathNavigator currentnavigator = navigator.SelectSingleNode("//*/value");
Can anyone give me some idea how to edit this node i.e. add value to it which can be a string path.
will get appended a开发者_Go百科t the end ?
If your navigator
is editable, you can just use SetValue()
:
currentnavigator.SetValue("somePath");
That being said, I would recommend you to use LINQ to XML instead, I find it much easier to use:
XDocument doc = …;
doc.Root.Element("value").Value = "somePath";
精彩评论