I'm trying to write an attribute value to an existing XDocument via a given XPath. But it seems the only way to do this is getting an element and then calling the attribute. Is there any way to write a attribute directly (in my case without splitting the given XPath to "/locations/group[@name="Client:UserData"]" for selecting the element and "/@root" for getting the attribute from the XElement object).
given XML (as XDocument):
<locations>
<group name="Client:UserData" root="\\appserver\Data" required="true">
<path name="some name" path="~\directory\file" required="false" autoCreate="false" />
</group>
</locations>
given XPath: /locations/group[@name="Client:UserData"]/@root
given value: "\appserver\anotherDirectory"
expected output (as XDocument):
<locations>
<group name="Client:UserData" root="\\appserver\anotherDirectory" required="true">
<path name="some name" path="~\directory\file" required="false" autoCreate="false" />
</group>
</locations>