title: Change the name of an XElement in linq to xml
body: <p>I have 2 xmls.SourceXml and TargetXml</p>
  
  <p>I am importing some elements of an xml into another xml.</p>
  
  <p>That is all good however Some Elements I just need to change the name. 
  What I am currently doing I am building the element from scratch with the only difference is the name of the xml.</p>
  
  <p>Let me give you an example.</p>
  
  <p>In my Source Xml I have an element called </p>
  
  <pre><code> &lt;OldBank&gt;
         &lt;SortCode&gt;123456&lt;/SortCode&gt;
         &lt;AccountNumber&gt;12345678&lt;/AccountNumber&gt;  
         etc....        
   &lt;/OldBank&gt;
  </code></pre>
  
  <p>In My Target xml should be called NewBank with the children element that are exactly the same</p>
  
  <pre><code>  &lt;NewBank&gt;
         &lt;SortCode&gt;123456&lt;/SortCode&gt;
         &lt;AccountNumber&gt;12345678&lt;/AccountNumber&gt;  
         etc....        
   &lt;/NewBank&gt;
  </code></pre>
  
  <p>This is what I do:</p>
  
  <pre><code>    public static void ReplaceNewCustomerDetails(this XDocument xDoc)
      {
          XElement oldBankElement = GetOldBankElement(xDoc);
  
         var newBakXml= new XElement("NewBank",
                       new XElement(oldBankElement.ElementOrDefault("SortCode")),
                       new XElement(oldBankElement.ElementOrDefault("AccountNumber")));
  
         //Build new xml. This is what I do
         var newXml = new XElement("MyNewXml");
         newXml.Add(newBakXml);
  
        //I wish I could just change the name of the xml rather then building it again
         var newXml = new XElement("MyNewXml");
         newXml.Add(oldBankElement.Name="NewBank");
  </code></pre>
  
  <p>Any suggestion or more elegant solution</p>
  
  <p>Thanks</p>