title: Update a Linq to XML Element with an Element
body: <p>I have an Add and an Update function to update a listing in an xml database I'm working on.  In the add function i do this:</p>
  
  <pre><code>new XElement(ImageUtilities.GetImageXElement(series.image)),
  </code></pre>
  
  <p>It basically takes an image object, does some background stuff (which works fine) and returns an XElement. This works flawlessly.  The problem comes when I am trying to do an update. I'm essentially trying to do the following.</p>
  
  <pre><code>xseries.SetElementValue(ImageUtilities.GetImageXElement(series.image));
  </code></pre>
  
  <p>I've tried the following which obviously doesn't work, but I am thinking that some variation of it will work, it compiles, but it wont run.  It gives the error: "System.ArgumentException: An XObject cannot be used as a value." I've googled it, and nothing seems to say, You update an element with an element by.</p>
  
  <pre><code>xseries.SetElementValue("image", ImageUtilities.GetImageXElement(series.image));
  </code></pre>
  
  <p>I am able to get it to work properly by doing:</p>
  
  <pre><code>xseries.Element("image").SetAttributeValue("guid", series.image.guid);
  xseries.Element("image").SetAttributeValue("main", series.image.main);
  xseries.Element("image").SetAttributeValue("height", series.image.height);
  xseries.Element("image").SetAttributeValue("width", series.image.width);
  xseries.Element("image").SetAttributeValue("order", series.image.order);
  ... and so on. 
  </code></pre>
  
  <p>but if the image object changes I'll have to go back in and change everything I've done later.</p>