title: how to add an attribute to an XML element
body: <p>I am using the DOM parser. I have to parse the following XML:</p>
  
  <pre><code>    &lt;abc&gt;
         &lt;type action=""&gt;
            &lt;code&gt;test&lt;/code&gt;
            &lt;value&gt;001&lt;/value&gt;
         &lt;/type&gt;
         &lt;type action=""&gt;
            &lt;code&gt;test2&lt;/code&gt;
            &lt;value&gt;002&lt;/value&gt;
         &lt;/type&gt;
      &lt;/abc&gt;
  </code></pre>
  
  <p>so, depending on the <code>value</code> field under the <code>type</code> field, I have to fill in the <code>action</code> attribute in the <code>type</code> field. I am a bit stumped. I am able to get the value of the <code>value</code> field, but I don't know how to go back and add the attribute.</p>
  
  <p>Any help will be appreciated a lot!!!</p>
  
  <p>thanks!</p>