title: How to add custom namespaces to an incoming XML message?
body: <p>What's the recommended way of adding namespaces to an incoming XML message which needs to be debatched? In order to debatch the incoming XML message I'm using an envelope as well as a "normal" message xsd schema which both have a target namespace. The incoming XML message doesn't have any namespaces attached in the first place.</p>
  
  <p>Thank you</p>
  
  <pre><code>using System;
  using System.Linq;
  using System.Xml.Linq;
  
  public class AddNamespaceRcvPipelineComponent
  {
      static public void Main ()
      {
          XElement xDoc = XElement.Load(@"test.xml");
  
          XNamespace ns1 = "Namespace1";
          XNamespace ns2 = "Namespace2";
  
          foreach (XElement el in xDoc.DescendantsAndSelf("ORDERS"))
          {
              // el.Add(new XAttribute(XNamespace.Xmlns + "ns1", "Namespace1"));
              el.Name = ns1 + el.Name.LocalName;
          }
  
          foreach (XElement el in xDoc.DescendantsAndSelf("ORDER"))
          {
              // el.Add(new XAttribute(XNamespace.Xmlns + "ns2", "Namespace2"));
              el.Name = ns2 + el.Name.LocalName;
          }
  
          // TODO: Strip empty namespaces ...
  
          Console.WriteLine(xDoc);
      }
  }
  </code></pre>