score:3

There are many problems with your code, starting with the fact that you posted invalid XML. Assuming that your XML was like this:

<CONFIGURATION NAME="HDD">
  <DECLARATION NAME="1ST_HDD_SATA">
    <INSTANCE>
      <PROPERTY  NAME="ControllerPosition" CHECKPOSITION="true">
        <INDEX>
          <VALUE>0</VALUE>
          <VALUE STEP="1">Std.flg</VALUE>
          <VALUE STEP="2">Sas.flg</VALUE>
          <VALUE STEP="-1">eS.flg</VALUE>
        </INDEX>
      </PROPERTY>
    </INSTANCE>
  </DECLARATION>
</CONFIGURATION>

Then the following code works:

var doc = XDocument.Load("Configuration.xml");

var hdd = from n1 in doc.Elements("CONFIGURATION").Elements("DECLARATION")
          let nameAttribute = n1.Attribute("NAME")
          where nameAttribute != null && nameAttribute.Value.Trim() == "1ST_HDD_SATA"
          select n1.Elements("INSTANCE")
                   .Elements("PROPERTY")
                   .Elements("INDEX")
                   .Elements("VALUE");
foreach (var elList in hdd)
    foreach (var el in elList)
    {
        el.ReplaceNodes("string");
    }

doc.Save("Configuration.xml");

Related Articles