title: Add prefixes and namespaces to XML serialization
body: <p>I'm working in a Mexican tax calculation program and the government provided the following XSD file <a href="http://www.sat.gob.mx/cfd/3/cfdv32.xsd">http://www.sat.gob.mx/cfd/3/cfdv32.xsd</a>, with xsd.exe help I have converted it to a C# class which is quite big so I'll just provide a link to it in order to no bloat this post with code:  <a href="http://pastebin.com/r3VCgFMU">http://pastebin.com/r3VCgFMU</a>.</p>
  
  <p>After filling SOME of the class fields (So the example doesn't get too big) I tried to serialize the XML as follows:</p>
  
  <pre><code>XmlSerializerNamespaces xmlNameSpace = new XmlSerializerNamespaces();
  xmlNameSpace.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance");
  xmlNameSpace.Add("schemaLocation", "http://www.sat.gob.mx/cfd/3/cfdv32.xsd");
  xmlNameSpace.Add("cfdi", "www.sat.gob.mx/cfd/3");
  XmlTextWriter xmlTextWriter = new XmlTextWriter("c:\\temp\\pruebas.xml", Encoding.UTF8);
  xmlTextWriter.Formatting = Formatting.Indented;
  XmlSerializer xs = new XmlSerializer(typeof(Comprobante));
  
  xs.Serialize(xmlTextWriter, comprobante, xmlNameSpace);
  xmlTextWriter.Close();
  </code></pre>
  
  <p>Which gives me this output:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Comprobante xmlns:cfdi="www.sat.gob.mx/cfd/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:schemaLocation="http://www.sat.gob.mx/cfd/3/cfdv32.xsd" version="3.2" fecha="0001-01-01T00:00:00" subTotal="0" total="0" tipoDeComprobante="ingreso" xmlns="http://www.sat.gob.mx/cfd/3"&gt;
    &lt;Emisor rfc="DERH9145202V4"&gt;
      &lt;DomicilioFiscal calle="Calle1" colonia="Colonia" municipio="municipio" estado="estado" pais="pais" codigoPostal="07000" /&gt;
      &lt;RegimenFiscal Regimen="Peque" /&gt;
    &lt;/Emisor&gt;
  &lt;/Comprobante&gt;
  </code></pre>
  
  <p>As we can see in an example provided by the government (ftp://ftp2.sat.gob.mx/asistencia_servicio_ftp/publicaciones/solcedi/ejemplo1%20cfdv3.xml) my generated file lacks some points:</p>
  
  <pre><code>&lt;Comprobante... should be &lt;cfdi:Comprobante 
  &lt;Emisor.. should be &lt;cfdi:Emisor 
  and so on and so forth with all elements...
  xmlns:schemaLocation should be xsi:schemaLocation  
  I'm getting and additional xmlns="http://www.sat.gob.mx/cfd/3" at the end of the Comprobante declaration
  </code></pre>
  
  <p>How can I achieve this changes in my xml? :D</p>