title: How can I add an attribute to an XML node based on another attribute?
body: <p>I have the following XML:</p>
  
  <pre><code>&lt;funds&gt;
      &lt;fund name="A" ITEM0="7%" ITEM1="8%" ITEM2="9%" ITEM3="10%" ITEM4="11%" ITEM5="" /&gt; 
      &lt;fund name="B" ITEM0="11%" ITEM1="11%" ITEM2="13%" ITEM3="14%" ITEM4="16%" ITEM5="" /&gt; 
      &lt;fund name="C" ITEM0="" ITEM1="" ITEM2="" ITEM3="" ITEM4="" ITEM5="" /&gt; 
      &lt;fund name="D" ITEM0="7%" ITEM1="8%" ITEM2="9%" ITEM3="10%" ITEM4="11%" ITEM5="" /&gt; 
      &lt;fund name="E" ITEM0="2%" ITEM1="3%" ITEM2="3%" ITEM3="5%" ITEM4="5%" ITEM5="" /&gt; 
      &lt;fund name="F" ITEM0="" ITEM1="" ITEM2="" ITEM3="" ITEM4="" ITEM5="" /&gt; 
      &lt;fund name="G" ITEM0="3%" ITEM1="3%" ITEM2="3%" ITEM3="5%" ITEM4="5%" ITEM5="" /&gt; 
  &lt;/funds&gt;
  &lt;ToAppend&gt;
      &lt;append name="A" ITEM="10" /&gt;
      &lt;append name="B" ITEM="15" /&gt;
      &lt;append name="C" ITEM="20" /&gt;
      &lt;append name="D" ITEM="20" /&gt;
      &lt;append name="E" ITEM="15" /&gt;
      &lt;append name="F" ITEM="10" /&gt;
      &lt;append name="G" ITEM="10" /&gt;
  &lt;/ToAppend&gt;
  </code></pre>
  
  <p>How can I loop through all of the attributes in //ToAppend/append and if 'name' is a match in //funds/fund add the attribute ITEM from //ToAppend/append to //funds/fund ?</p>
  
  <p>I'm trying to append the matching items to the first list but I'm not having too much luck.  Trying to get this working via C# under the 2.0 framework.</p>
  
  <p>Thanks in advance!</p>
  
  <p>edit:</p>
  
  <pre><code>XmlNode xmlNodeInner = root.SelectSingleNode("//ToAppend/append");
  XmlNode ToBeUpdated = root.SelectSingleNode("//funds/fund");
  
  foreach (XmlElement element in ToBeUpdated)
      {
          Console.WriteLine(element.InnerXml);
         //Match the 'name' from xmlNodeInner to the 'name' of ToBeUpdated
         //if{magic occurs here and they match}
          {
              element.SetAttribute("ITEM6", "value from xmlNodeInner");
         }
      }
  </code></pre>
  
  <p>I just dont know how to do the comparison inquiry to determine if A=A, or even exists, since there is no guarentee on that.
  Hopefully it would come out something like:</p>
  
  <pre><code>&lt;fund name="G" ITEM0="3%" ITEM1="3%" ITEM2="3%" ITEM3="5%" ITEM4="5%" ITEM5="" ITEM6="10"/&gt; 
  </code></pre>