title: What's the easiest method to change the namespace value using LINQ to XML?
body: <p>TL/DR: What's the easiest method to change the namespace value using <code>LINQ to XML</code>, say from <code>xmlns:gcs="clr-namespace:NsOne;assembly=AsmOne"</code> to <code>xmlns:gcs="clr-namespace:NsTwo;assembly=AsmTwo"</code>?</p>
  
  <p>Why? because:</p>
  
  <p>I serialized <code>Xaml</code> using <code>System.Windows.Markup.XamlWriter.Save(myControl)</code>. I want to visualize this GUI appearance somewhere else (deserializing using <code>System.Windows.Markup.XamlReader.Parse(raw)</code>), in another project.</p>
  
  <p><strong>I don't want to link to the original assembly!</strong></p>
  
  <p>I just need to change the namespace, so <code>XamlReader.Parse(raw)</code> won't throw an exception. I currently do it using regular-expressions <strong>and it works</strong>, but I don't like that method (e.g. if I have <code>xmlns:gcs="clr-namespace:NsOne;assembly=AsmOne"</code> inside a <code>CDATA</code>)</p>
  
  <p>This is my serialized <code>Xaml</code>:</p>
  
  <pre><code>&lt;FlowDocument PagePadding="5,0,5,0" AllowDrop="True"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:gcs="clr-namespace:NsOne;assembly=AsmOne"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt;
  
      &lt;gcs:MyParagraph Margin="0,0,0,0"&gt;
          &lt;gcs:MyParagraph.MetaData&gt;
              &lt;gcs:ParagraphMetaData UpdaterParagraphUniqueId="1" /&gt;
          &lt;/gcs:MyParagraph.MetaData&gt;
          &lt;Span&gt;some text...&lt;/Span&gt;
      &lt;/gcs:MyParagraph&gt;
      &lt;gcs:MyParagraph Margin="0,0,0,0" Background="#FFF0F0F0"&gt;
          &lt;gcs:MyParagraph.MetaData&gt;
              &lt;gcs:ParagraphMetaData UpdaterParagraphUniqueId="2" /&gt;
          &lt;/gcs:MyParagraph.MetaData&gt;
          &lt;Span Foreground="#FF0000FF"&gt;some more text...&lt;/Span&gt;
      &lt;/gcs:MyParagraph&gt;
  &lt;/FlowDocument&gt;
  </code></pre>
  
  <p>(<code>MyParagraph</code> and <code>ParagraphMetaData</code> are custom types and they both exist at the source assembly and the destination assembly. <code>MyParagraph</code> inherits <code>WPF</code>'s <code>Paragraph</code>)</p>