title: How to add prefix in front of xml element using attribute in c#
body: <p>with the programming is this:</p>
  
  <p>As a result I want to have this:</p>
  
  <pre><code>&lt;rootprefix:rootname 
       noPrefix="attribute with no prefix"
       firstprefix:attrOne="first atrribute"
       secondprefix:attrTwo="second atrribute with different prefix"&gt;
  
       ...other elements...
  
   &lt;/rootprefix:rootname&gt;
  </code></pre>
  
  <p>The way to do this by coding is:</p>
  
  <pre><code>NameTable nt = new NameTable();
  nt.Add("key");
  
  XmlNamespaceManager ns = new XmlNamespaceManager(nt);
  ns.AddNamespace("firstprefix", "fp");
  ns.AddNamespace("secondprefix", "sp");
  
  root.SetAttribute("attrOne", ns.LookupPrefix("fp"), "1st attribute");
  root.SetAttribute("attrTwo", ns.LookupPrefix("sp"), "2nd with different prefix");
  </code></pre>
  
  <p>But I want to do this using attributes of types above of the class declaration. 
  For eg: <code>[XmlType(Namespace = "bb:aaaa")]</code> or something else.</p>
  
  <p>How can I do this?</p>
  
  <p>Edit:
  My class something like this:</p>
  
  <pre><code>[XmlRoot("Node", Namespace="http://flibble")]
  public class MyType {
      [XmlElement("chileNode")]
      public string Value { get; set; }
  }
  </code></pre>
  
  <p>And I want to have this result:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ibm857"?&gt;
  &lt;myNamespace:Node xmlns:myNamespace="http://hede.com" /&gt;
  </code></pre>
  
  <p>Without writing this code:</p>
  
  <pre><code>static class Program
  {
      static void Main()
      {
          XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
          ns.Add("myNamespace", "http://hede.com");
          XmlSerializer xser = new XmlSerializer(typeof(MyType));
          xser.Serialize(Console.Out, new MyType(), ns);
      }
  }
  </code></pre>
  
  <p>With some attribute like this:</p>
  
  <pre><code>[XmlRoot("Node", Namespace="http://hede.com", NamespacePrefix="myNamespace")]
  public class MyType {
      [XmlElement("chileNode")]
      public string Value { get; set; }
  }
  </code></pre>
  
  <p>But I couldn't find a way putting "myNamespace" prefix in front of xml tag.</p>