I have the following xml file
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfParams xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Params Key="Domain" Value="User123">
<Variable>
<Name>Domain</Name>
<Type>String</Type>
<Value>User123</Value>
</Variable>
</Params>
<Params Key="Password" Value="Password123">
<Variable>
<Name>Password</Name>
<Type>String</Type>
<Value>Password123</Value>
</Variable>
</Params>
<Params Key="Username" Value="Domain123">
<Variable>
<Name>Username</Name>
<Type>String</Type>
<Value>Domain123</Value>
</Variable>
</Params>
</ArrayOfParams>
I would like to change the password from Password123 to NewPassword123
The xml should be changed in 2 places:
<Params Key="Password" Value="Password123">
and
<Value>Password123</Value>
How can this be done?
EDIT the XML already exist, not my design. i just need to change it
I tried to use XDocument, but am having problems with the query.
can you provide a linq that knows how to query it?
How about using LINQ to XML?
After that you can save the document wherever you want.
I can’t test it right now, but general idea should be clear.